You are on page 1of 2

8/3/2015 Orchard Project - [SOLVED] Admin page - Change "View Your Site" to site's name?

(multiple tenants)

CodePlex Project Hosting for Open Source Software Register Sign In Search all projects

HOME SOURCE CODE DOWNLOADS DOCUMENTATION DISCUSSIONS ISSUES PEOPLE LICENSE

New Thread Subscribe

[SOLVED] Admin page - Change "View Your Site" to site's name? (multiple
tenants)
Topics: Administration, Customizing Orchard Wiki Link: [discussion:285916]

DinoStar I saw this post on WHERE to change the "View Your Site" link that you get on the top left of the
Jan 12, 2012 at 1:54 Dashboard: http://orchard.codeplex.com/discussions/275621
PM
Edited Jan 12, 2012 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
at 1:55 PM 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.

randompete I'd love to see better all-round support in the future for rebranding admin per tenant!
Jan 12, 2012 at 2:06
PM However for the time being it's pretty easy to get the site name in there: WorkContext.CurrentSite.SiteName

DinoStar Thanks randompete. I was trying to use the WorkContext, but being a n00b I haven't quite figured out how. :)
Jan 12, 2012 at 2:13
PM 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.

randompete I'd say there's no point localizing the site name, so just use:
Jan 12, 2012 at 2:53
PM <div id="site">@Html.ActionLink(WorkContext.CurrentSite.SiteName, "Index", new { Area = "", Controller
Edited Jan 12, 2012 = "Home" })</div>
at 2:53 PM

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).

Explanation:

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.

https://orchard.codeplex.com/discussions/285916 1/2
8/3/2015 Orchard Project - [SOLVED] Admin page - Change "View Your Site" to site's name? (multiple tenants)

DinoStar 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
Jan 12, 2012 at 7:00 solution I couldn't see the site name. I inspected the CSS and it was showing up below and behind the menu. Increasing the
PM width of the menu background helped out.

randompete Hmm, it worked fine for me, and it works fine by default; maybe you changed something in the HTML or CSS by accident?
Jan 12, 2012 at 8:49
PM

Sign in to post message or set email notifications

© 2006-2015 Microsoft Get Help Privacy Statement Terms of Use Code of Conduct Advertise With Us Version 7.7.2015.21028

https://orchard.codeplex.com/discussions/285916 2/2

You might also like