Jump to:

1384 Posts in 493 Topics by 522 members

Themes

SilverStripe Forums » Themes » Menu() in <head>

Discuss SilverStripe Themes.

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

Page: 1
Go to End
Author Topic: 910 Views
  • patr547
    Avatar
    Community Member
    3 Posts

    Menu() in <head> Link to this post

    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!

    910 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.