Get resource string in page template layout

GTEK IT DEV Team asked on May 9, 2018 12:31

Hi all,

I'm trying to get the value of a resource string in layout tab in a page template.

My macro syntax {% GetResourceString("MyResourceString") #%}

But the result i received was like that. {% GetResourceString("MyResourceString") |(identity)GlobalAdministrator|(hash)381cc48954e7fcfdfaf7163c5274b46ff6100b44b307828bf5d420d24f78582c%}

I don't understand what happend !

Correct Answer

Peter Mogilnitski answered on May 9, 2018 13:18

you resources macro syntax is correct. What you see on the screen means that macro is not resolved. Macro syntax does not work in acsx transformation because it is essentially a web control, but you can call c# methods directly :

<%=CMS.Helpers.ResHelper.GetString("resourcestringname")%>
<%=CMS.MacroEngine.MacroResolver.Resolve("The current user is: {% CurrentUser.UserName |(identity)GlobalAdministrator%}") %>
0 votesVote for this answer Unmark Correct answer

Recent Answers


Dawid Jachnik answered on May 9, 2018 12:52

Hi, There is ascx layout so you should use .NET syntax

<%#ResHelper.LocalizeString("{$MyResourceString$}") %>
0 votesVote for this answer Mark as a Correct answer

GTEK IT DEV Team answered on May 9, 2018 12:59

Thanks you for your help Dawid, but when is used this syntax. It just return an empty string.

0 votesVote for this answer Mark as a Correct answer

Dawid Jachnik answered on May 9, 2018 13:02

Did you leave the {$ $} ?

0 votesVote for this answer Mark as a Correct answer

Dawid Jachnik answered on May 9, 2018 14:02

Peter, decide which option is good, because I see right now third version of your answer ;)

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on May 9, 2018 14:12 (last edited on May 9, 2018 15:26)

It is always the last version :), I just thought it doesn't make any sense to put those strings in the layout It should be a web part in the design tab. Later on to find where this text is coming from would be a nightmare.

0 votesVote for this answer Mark as a Correct answer

GTEK IT DEV Team answered on May 10, 2018 04:18 (last edited on May 10, 2018 04:18)

Hi guys,

Dawid, I put the $ character at start and the end of the resource string name. But result was empty

Peter, this syntax work for me, thank you. <%=CMS.Helpers.ResHelper.GetString("resourcestringname")%>

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.