Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modify Footer in Orchard CMS

I have tried searching for the answer to this, but none of the solutions seem to show how to modify the footer. I see this in the view for the theme:

    <div id="footer-sig" class="group">
        @Zone(Model.Footer)
    </div>

How do I modify Model.Footer? I have the release version that I installed from the Web Installer, and it doesn't seem to have controllers or models in it, just views. How can I modify the footer?

For instance, I just want to put a "|" in between the dashboard and other links.

like image 382
user1477388 Avatar asked Dec 26 '22 21:12

user1477388


2 Answers

If you haven't already done so, it's probably worth reading some background on customising Orchard themes.

This depends a lot on what it is you want to change about Model.Footer. Assuming you're using the TheThemeMachine theme, the code snippet that you've posted is contained in Layout.cshtml. If you look further up the source, you'll see the snippet:

WorkContext.Layout.Footer.Add(New.BadgeOfHonor(), "5"); // Powered by Orchard
WorkContext.Layout.Footer.Add(New.User(), "10"); // Login and dashboard links

This is telling Orchard to spin up two new shapes as part of the footer (BadgeOfHonor and User).

The BadgeOfHonor shape simply renders the view which is bundled into TheTimeMachine theme so can be easily changed.

The User shape has a default view in the core and renders the 'Welcome XXX / Sign in' element of the footer. This can be overridden by your theme in the usual Orchard way.

From your comment, it sounds like you want to change the footer from TheThemeMachine, so that instead of saying:

Powered by Orchard © The Theme Machine 2010. Welcome, admin! Sign Out Dashboard

It says:

Powered by Orchard © The Theme Machine 2010. Welcome, admin! Sign Out | Dashboard

You can override views in Orchard by creating the appropriate view within your Theme. So, to change the way that the User shape is rendered, you just need to add the view to your theme and modify it. The easiest way to do that is to go and find the existing view and copy it into your theme, which will give you something to work from. In this instance, the file src\Orchard.Web\Core\Shapes\Views\User.cshtml would need to be copied into the folder src\Orchard.Web\Themes\TheThemeMachine\Views\User.cshtml (assuming you're modifying TheThemeMachine). Then you would just need to change this code:

    <span class="user-actions">
        @Html.ActionLink(T("Sign Out").ToString(), "LogOff", new { Controller = "Account", Area = "Orchard.Users", ReturnUrl = Context.Request.RawUrl }, new { rel = "nofollow" })
        @if (AuthorizedFor(Orchard.Security.StandardPermissions.AccessAdminPanel)) {
            @Html.ActionLink(T("Dashboard").ToString(), "Index", new {Area = "Dashboard", Controller = "Admin"})
        }
    </span>

into something like this:

    <span class="user-actions">
        @Html.ActionLink(T("Sign Out").ToString(), "LogOff", new { Controller = "Account", Area = "Orchard.Users", ReturnUrl = Context.Request.RawUrl }, new { rel = "nofollow" })
        |
        @if (AuthorizedFor(Orchard.Security.StandardPermissions.AccessAdminPanel)) {
            @Html.ActionLink(T("Dashboard").ToString(), "Index", new {Area = "Dashboard", Controller = "Admin"})
        }
    </span>

Generally, It's a good idea to work on your own copy of a Theme, rather than directly modifying the ones that come with the distribution as this will make it easier for you to take updates when they come. It's also worth looking into how ShapeTracing module, which allows you to identify which shapes you need to override to change different elements on your site. The documentation on the Orchard.Net pages do contain some useful information (although it can get a bit out of date because the development is still moving quite quickly), so it's worth a read.

like image 143
forsvarir Avatar answered Dec 31 '22 07:12

forsvarir


One easy way out is to explore your the website files and find ~\Themes[ThemeNameOverHere]\Views\BadgeOfHonor.cshtml
Mine has this has it's content which you can easily edit: @T("Powered by Orchard", "http://www.orchardproject.net") @T("© The Theme Machine 2010.")

Note: Am using Orchard 1.9.1 Version. Hope this is useful.

like image 25
Abisoye Falabi Avatar answered Dec 31 '22 08:12

Abisoye Falabi