Jump to:

3447 Posts in 1032 Topics by 872 members

Template Questions

SilverStripe Forums » Template Questions » layout and menu-structure based on value of a toplevel cms-field - help needed!!!

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

Page: 1
Go to End
Author Topic: 988 Views
  • theAlien
    Avatar
    Community Member
    131 Posts

    layout and menu-structure based on value of a toplevel cms-field - help needed!!! Link to this post

    Hi,

    I'm really breaking my head over this one:
    I have a field "Layout" in all of my toplevel pages (with if(!this->parent){}).
    On all children-pages I want to check what's the value of that field.

    Based on that value I want to render a specific div-structure.
    Next to that, the value is used to determine if the menu starts at level 1 or level 2.

    So for example: if Layout = Youth, it has to render a menu on level 2 and is Layout = General, it has to render a menu on level 1.

    Right now, I have the following code:

    <% control Level(1) %>
    <% if Layout = General %>
    <div id=General>$MenuTitle.XML</div>
    <% else_if Layout = Youth %>
    <% control Children %>
    <div id=Youth1>$MenuTitle.XML</div><div id=Youth2></div>
    <% end_control %>
    <% else_if .........
    <% end_if %>
    <% end_control %>


    I thought that would be translated as: Check the data on level 1: if $layout on level 1 is General: use the general-behaviour. if $layout on level 1 is Youth, use the youth-behaviour. But apparently I'm wrong.

    It works on all toplevel pages. If Layout = Youth: the toplevel-menu is replaced by a second-level menu and both div's are shown. However: after clicking on one of the second-level menuitems, everything is set back to the default layout, including the toplevel-menu.

    I've tried the subsites module (that would be the best) but I can't get it working (I'm using a shared host and haven't DNS-access). That's why I'm trying this workaround. Does someone now what I'm doing wrong or what I could do better?

    988 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.