How to get site name in transformation?

Ashutosh Pandey asked on December 17, 2018 09:02

I am developing my site on local first and then deploy on production. I am working on transformation. I am displaying an image like this:

<img src='/MySite/localhost/MyTheme/images/<%# Eval("Logo") %>'/>

But, I want to use a variable to insert 'localhost' or 'sitename' using a variable but following are not working:

<img src='/MySite/{%SiteContext.CurrentSiteName%}/MyTheme/images/<%# Eval("Logo") %>'/> or <img src='/MySite/{%CurrentSiteName%}/MyTheme/images/<%# Eval("Logo") %>'/>

Is there any macro available to use in transformation or am I doing something wrong?

Correct Answer

David te Kloese answered on December 17, 2018 10:31

When using Text/XML transformation it should just work with

1 {% CurrentSite.SiteName |(identity)GlobalAdministrator%}

When using ASCX transformation you could use:

<%# CurrentSite.SiteName %> Or make sure you include the full namespace:

<%# CMS.SiteProvider.SiteContext.CurrentSiteName %>

2 votesVote for this answer Unmark Correct answer

Recent Answers


Ashutosh Pandey answered on December 17, 2018 13:26

Thanks David, this one worked:

<%# CurrentSite.SiteName %>

0 votesVote for this answer Mark as a Correct answer

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