Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Themes /

Discuss SilverStripe Themes.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Menu() in <head>


Reply


941 Views

Avatar
patr547

Community Member, 3 Posts

13 August 2009 at 1:00am

I'm trying to use the Menu() function in the <head> section of Page.ss to determine if I should include a CSS file which is configured for content to take the whole width of the page or leave room for the sidebar. (My reasoning is that I don't want that extra space for the sidebar on the page if there isn't going to be one, and leaving it as auto doesn't work right in Firefox..fine in IE though...) But when I try to put it there, or try to use it in initialization for Page_Controller, pages never load, and I don't get any error messages. My assumption is that the Menu function can't be called that early on in the game.

This is the code I'm trying to use (this is what I tried in Page_Controller.init():
if(Menu(2)) {
   Requirements::themedCSS("layout-withside");
} else {
   Requirements::themedCSS("layout-noside");
}

And, this is what I tried in Page.ss before I tried it that way:
<% if Menu(2) %>
   <% require themedCSS("layout-withside") %>
<% else %>
   <% require themedCSS("layout-noside") %>
<% end_if %>

If anyone has any has any ideas it would be greatly appreciated. Or any workarounds for the CSS, which I will include below..the files are very basic, it is only to get around the fact that Firefox doesn't seem to think of width:auto; the same as IE does.

[layout-noside.css]
#Content {
   width: 100%;
   float: left;    
   margin: 0;
   text-align: left;
}

[layout-withside.css]
#Content {
   width: 540px;
   float: left;    
   margin: 0;
   text-align: left;
}

Thanks!