Close

How to not show logo on home page?

joster
8 years ago
#10138 Quote
Avatar
  • 130
Hello-

I am adding our company logo to our main slider images, and I am wanting to stop the theme-defined logo from appearing on the home page ONLY.

I opened my /Views/Shared/_Root.cshtml and see this variable is defined:
    isHomePage = true;


Further down on same view, I see where the Header page is called:
<div class="home-page-header main-slider-header">
  @Html.Partial("Header")
</div>


But in the Header.cshtml, when I try to reference the "isHomePage" variable:

@if (isHomePage)
        {
@* do not show logo  *@
        }
        else
        {
        <a href="@Url.RouteUrl("HomePage")" class="logo">
            @if (!MvcHtmlString.IsNullOrEmpty(alfrescoLogo))
            {
                @alfrescoLogo
            }
            else
            {
                string storeName = EngineContext.Current.Resolve<IStoreContext>().CurrentStore.GetLocalized(x => x.Name);
                <img title="" alt="@storeName" src="@Url.Content(logoPath)">
            }
        </a>
        }



....I get this error:
The name 'isHomePage' does not exist in the current context

My question is:
Isn't it possible for a partial view to see the variables defined on it's parent/calling document?

If so, on the Header.cshtml, how can I properly refer to the variable created on _Root.cshtml for my conditional code to execute correctly?

Thank you!

 
Stefan
8 years ago
#10143 Quote
Avatar
  • Moderator
  • 157
Hi joster,

Unfortunately all variables defined in a view or partial view can be accessed and used only in that view. So that is why you receive the error described.
However you can very easily hide the logo only on the home page by using the css class that is added only on the home page. Just add the following css in your admin -> plugins -> 7spikes themes -> nop alfresco theme -> settings -> custom head styles textbox:

.master-home-page .header-logo {display:none !important;}


Hope that helps.
Best Regards,

Stefan Hristov
Nop-Templates.com
joster
8 years ago
#10148 Quote
Avatar
  • 130
That's a perfect solution.

Many thanks!