Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5948967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:11:01+00:00 2026-05-22T17:11:01+00:00

I am working on a silverstripe subdomains’ issue, someone else did the code, so

  • 0

I am working on a silverstripe subdomains’ issue, someone else did the code, so any help would be appreciated.

There is a “About Us” nav bar on the main website eg http://www.mainwebsite.com, and we would like the “About Us” to disappear for any subdomains eg subdomain.mainwebsite.com.

I can see from the Silverstripe backend, there is a ‘Hide in Subdomains’ function, and I ticked it. However, the “About Us” link disappears for some time and it comes back at other tomes on both main site and subdomains.

Can anybody point me to the right direction how can I fix this problem? I can copy any code here if you need. Please help.

Thanks heaps,
S:)

add comments, I have found this code in my page.php in my site – code folder if it is useful

function ShowMenuInSubdomain()
{
    $host = explode('.',$_SERVER['HTTP_HOST']);
    $subdomain = $host[0];
    if($subdomain != 'www' && $this->HideInSubdomains) {
        return true;    
    }       
}

add comments, here is navigation part in Page.ss in the theme – templates folder I am using

<div id="Header">
    <div id="HeaderWrapper">
        <div id="LogoWrapper"><a href="{$BaseHref}">$GetSubDomainHeaderImage</a></div>
        <div id="Navigation">
            <% cached 'Navigation', Aggregate(Page).Max(LastEdited) %>
            <% include Navigation %>
          <% end_cached %>
        </div>
    </div>
</div>

add comments, here is what my navigation.ss in the templates – includes folder looks like

<ul>
<% control Menu(1) %>
    <% if ShowMenuInSubdomain %>
    <% else %>
    <li <% if Children %>class="hasChildren"<% end_if %>>
    <a href="$Link" title="$Title.XML" class="$LinkingMode">$MenuTitle.XML <% if ShowMenuInSubdomain %>0<% end_if %></a>
        <% if Children %>
        <ul>
        <% control Children %>
            <li <% if Children %>class="hasChildren"<% end_if %>>
            <a href="$Link" title="$Title.XML" class="$LinkingMode">$MenuTitle.XML</a>
            <% if Children %>
            <ul>
            <% control Children %>
            <ul class="thridUL{$Pos}">
                <% if DisableLink %>
                <li>
                <span class="$LinkingMode thirdLevelTitle lookLikeALink">$MenuTitle.XML</span>
                </li>
                <% else_if ShowLabelInMenu==0 %>
                <li>
                <a href="$Link" title="$Title.XML" class="$LinkingMode thirdLevelTitle">$MenuTitle.XML</a>
                </li>
                <% end_if %>
                <% if Children %>
                <% control Children %>
                <li>
                <a href="$Link" title="$Title.XML" class="$LinkingMode">$MenuTitle.XML</a>
                <% if Summary %>
                    <span class="menuSummary">
                        $Summary
                        <span class="menuSummaryThumb">$Thumbnail.PaddedImage(160, 160)</span>
                    </span>
                <% end_if %>
                </li>
                <% end_control %>
                <% end_if %>
            </ul>
            <div class="clear">&nbsp;</div>
            <% end_control %>
            </ul>
            <% end_if %>
            </li>
        <% end_control %>
        </ul>
        <% end_if %>
    </li>

    <% end_if %>
<% end_control %>
<li id="calculatorWrapper">
 <a id="Calculator" href="$distanceCalculator.Link" rel="shadowbox;height=800;width=1000"><span>Journey Planner</span></a>
</li> </ul>

Sorry it is a bit long but any help is appreciated. Thanks.

Hi everyone, it seems to be working
now when I deleted <% cached
‘Navigation’,
Aggregate(Page).Max(LastEdited) %> <%
end_cached %> in page.ss. Can someone
please kindly explain what was this
line for or the meaning of it? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:11:01+00:00Added an answer on May 22, 2026 at 5:11 pm

    as you’ve already found a method to the subodmain check for you (‘ShowMenuInSubdomain’), look now for the template where the menu is rendered. for a standard silverstripe installation this is most probably /mysite/templates/Page.ss, or one of the files in /mysite/templates/layout.

    your menu might be rendered inside a block like the following:

    <ul>
    <% control Menu(1) %>  
    <li><a href="$Link" title="Go to the $Title page" class="$LinkingMode">$MenuTitle</a></li>
    <% end_control %>
    </ul>
    

    you just have to wrap the list item then with a control block calling your ShowMenuInSubdomain function like so:

    <% if ShowMenuInSubdomain %>
    <li><a href="$Link" title="Go to the $Title page" class="$LinkingMode">$MenuTitle</a></li>
    <% end_if %>
    

    please post the corresponding template code block in case you’re having trouble with this.

    NOTE: i think there’s a ‘!’ missing in your ShowMenuInSubdomain function, as it currently reads like ‘if (HideInSubdomains) then ShowMenuInSubdomain is true’, so the line in question should probably be:

    if($subdomain != 'www' && !$this->HideInSubdomains) {
    

    (watch out for the ‘!’ before $this->HideInSubdomains)

    EDIT

    first, forget about the GetSubDomainMenu function, looks as though it’s been replaced by the much cleaner solution of using the built-in Menu control in conjunction with ShowMenuInSubdomain function for the subdomain check.

    second, forget about my note on the missing ‘!’ before $this->HideInSubdomains above. from the way the function is used i can see that it does what it’s supposed to, the function is just named in a misleading way: ShowMenuInSubdomain should read HideMenuInSubdomain. confusing, but not the source of the problem, apparently.

    so, from the code you’ve posted so far, there is no visible mistake, so you should try to verify the following:
    a) is the ‘navigation.ss’ (NOT .cc as you’ve posted i guess) actually the template that’s rendered? just add some test output inside the file to be sure (and add ‘?flush=1’ to your url to clear the template cache)
    b) does the ShowMenuInSubdomain function actually get called? make it return some string like ‘return “working”‘ in the first line, then add $ShowMenuInSubdomain to your template

    in case you’re still stuck then, you may zip your silverstripe project folder and put it somewhere for download (remove critical info like db access credentials first!), so i can have a look.
    good luck!

    EDIT II – SOLUTION – FINALLY 🙂

    looks as though you found the flawed code part. the lines you’ve deleted were supposed to cache the navigation, so it doesn’t have to get assembled each time it’s rendered (i guess you’re familiar with the concept of ‘caching’). have a look at the silverstripe docs on partial caching for further explanations on this. watch out for the first code snippet under ‘Aggregates’ there – it’s exactly the code you’ve deleted.

    but why does removing the caching part solve your problem? in fact, the answer is quite simple: as your cached navigation will only update after editing some page, the subdomain checking function won’t be called unless then too, wheter you’re on a subdomain or not. it’s that easy sometimes 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working on this page: http://www.karlsenner.dreamhosters.com/about.php and having trouble with the navigation in IE6. It
Working on some matrix code, I'm concerned of performance issues. here's how it works
Working on some legacy hibernate code. How do I do the following with hbm.xml(hibernate
Working with MVC 2 ad with the help of some friends I thought all
Working SQL The following code works as expected, returning two columns of data (a
Working with COM interop, I can call a managed function from within unmanaged code.
working on an old translation sample code for windows phone 7. Recently, I have
I'm trying to implement Recaptcha to Silverstripe, it is all working well but the
Working Example: This is almost identical to code I use in another places on
I'm working on a site which was coded with Silverstripe, I've got a problem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.