Jump to:

3431 Posts in 1025 Topics by 864 members

Template Questions

SilverStripe Forums » Template Questions » Checking parent value from within a <% control %>

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

Page: 1
Go to End
Author Topic: 1463 Views
  • Laurie
    Avatar
    Community Member
    21 Posts

    Checking parent value from within a <% control %> Link to this post

    I have a sidebar with highlight items grouped into different sections...

    Projects
    - Project Highlight 1
    - Project Highlight 2

    Publications
    - Publication Highlight 1
    - Publication Highlight 2

    On one particular type of page I would like to include some additional text below some of the highlight sections. However, I can't figure out how to get the <% if %> to check the proper variable from within the control block.

    <% control Highlights %>
    <h3>$Section</h3>
    <ul>
    <% control Items %>
    <li>$Blurb</li>
    <% end_control %>
    </ul>

    <% if page is of a particular type %>
    <% if Section = Projects %>
    <p>Extra project text</p>
    <% end_if %>
    <% if Section = Publications %>
    <p>Extra publications text %>
    <% end_if %>
    <% end_if %>
    <% end_control>

    So what I want is the <% if page is of a particular type %> to check the ClassName value for the page...which I understand in theory is considered a parent to the control block...but how do I write that within the <% if %>. I've tried <% if ClassName = ProjectPage %>, <% if Top.ClassName = ProjectPage %>, and <%if Parent.ClassName = ProjectPage %> all to no avail.

    Thanks.

  • sonet
    Avatar
    Community Member
    33 Posts

    Re: Checking parent value from within a <% control %> Link to this post

    You could create an extended_sidebar.ss for the particular page type where you want the additional information to appear and for all other page types include your default sidebar sub-template.

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