Customize the logo - Branding

Topics: Administration
Sep 26, 2012 at 8:54 AM


On my current website, I have the branding displaying the title of the current website.

I would like to replace the title from an gallery's image. So to do it, I create a new Views\Branding.cshtml and put inside.

@{    var homeUrl = Href("~/");}<h1 id="branding"><a href="@homeUrl"><img src="/OrchardLocal/Media/Default/ImageGalleries/Title/title_coinlecture.png" /></a></h1>

It works.

I would like to do the same thing by using Widgets, so in Header, I add a Html Widget.

and add in the body <img src="/OrchardLocal/Media/Default/ImageGalleries/Title/title_coinlecture.png" />.

I click on save and remove from visual studio Branding.cshtml. 

I refresh the website and I can see my image and the title of the website below.

So my idea is to "empty" the component with the title of the website and to add a link to the current website inside the Html Widget (to reuse the widget later in other cases if necessary).

So I create 



I remove the content of Branding.cshtml (@{    var homeUrl = Href("~/");}<h1 id="branding"><a href="@homeUrl">@WorkContext.CurrentSite.SiteName</a></h1>)

And in the Parts.Common.Body.cshtml I have

@{    var homeUrl = Href("~/");}<a href="@homeUrl">@Model.Html</a>

So it works, except I notice the "zone" around the title is too large.

By using ShapeTracing, I can see in Share Zone, Active Template Orchard.Core.Shapes.CoreSharepes::Zone. I try to create an alternate.

I obtain an error in C:\Orchard\src\Orchard\FileSystems\Dependencies\WebFormsExtensionsVirtualPathProvider.cs"The relative virtual path 'Orchard.Core.Shapes.CoreShapes::Zone' is not allowed here."

I think it's not the better way to do it, reduce the zone or maybe remove the zone to permit to have only the widget html.

Maybe should I modify a css.

What is your opinion?

Best regards,





Oct 5, 2012 at 6:57 AM

That error is a know issue with the Shape Tracer, so for now you can manually create a Zone.cshtml file in your Views folder if you want to override it. I never tried this so I'm not sure what you would have to put there. Probably a @DisplayChildren(Model) to render the child shapes. Look at the implementation of CoreShapes::Zone for clues. You could also generate alternates for the Zone shape using a custom ShapeTableProvider class, so that you only override the Zone template for the specific cases that you need.

In any case, the wrapping <div> element should not normally take up extra visual space, so some CSS trickery may solve your issue as well.