This project is read-only.

[SOLVED] Admin page - Change "View Your Site" to site's name? (multiple tenants)

Topics: Administration, Customizing Orchard
Jan 12, 2012 at 2:54 PM
Edited Jan 12, 2012 at 2:55 PM

I saw this post on WHERE to change the "View Your Site" link that you get on the top left of the Dashboard:

However, I am running multiple sites so a static change will not work for me. Is there a way to change the code (i.e., has anyone done this before)?

Current code in TheAdmin\Views\Header.chstml:

<div id="site">@Html.ActionLink(T("View Your Site").ToString(), "Index"new { Area = "", Controller = "Home" })</div>

I am not sure how to change the "...@Html.ActionLink(T("View Your Site").ToString()..." to read the current site or if that's even possible.

As always, advanced thanks for any help/guidance.

Jan 12, 2012 at 3:06 PM

I'd love to see better all-round support in the future for rebranding admin per tenant!

However for the time being it's pretty easy to get the site name in there: WorkContext.CurrentSite.SiteName


Jan 12, 2012 at 3:13 PM

Thanks randompete. I was trying to use the WorkContext, but being a n00b I haven't quite figured out how. :)

I tried (T(WorkContext.CurrentSite.SiteName) with no luck. I also looked at Core/Shapes/Views/Document.cshtml to get an idea of how the site name is placed in the <title> element, but that didn't work.

I will keep fiddling and post my results.

Jan 12, 2012 at 3:53 PM
Edited Jan 12, 2012 at 3:53 PM

I'd say there's no point localizing the site name, so just use:

<div id="site">@Html.ActionLink(WorkContext.CurrentSite.SiteName, "Index", new { Area = "", Controller = "Home" })</div>

However if you do ever want to use localization in an ActionLink, use: T("Foo").Text

(The existing template appears to use .ToString() instead of .Text, this works of course, but .Text is normal and neater).


T("Something") returns a LocalizedString result. The @ symbol in a .cshtml file will automatically convert that to a string and output it. However when you're making a function call to ActionLink it expects an actual String, and doesn't understand what to do with a LocalizedString object. So you need to call the .Text property to get a String result out.

Jan 12, 2012 at 8:00 PM

Thanks! It worked.  Just a note (and I may have had it right before), but teh CSS may play tricks.  When I first tried your solution I couldn't see the site name. I inspected the CSS and it was showing up below and behind the menu. Increasing the width of the menu background helped out.

Jan 12, 2012 at 9:49 PM

Hmm, it worked fine for me, and it works fine by default; maybe you changed something in the HTML or CSS by accident?