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.

Data Model Questions /

Up two levels, $Top.Top.Value ?


Reply


3 Posts   1199 Views

Avatar
JMagnusson

Community Member, 29 Posts

9 September 2011 at 1:54am

Hello!
I am trying to reach two levels up. See this:

      <!-- ============================ Here will go a slider ========================== -->
<div id="slides">
   <div class="slides_container">
      <div id="gallery">
         <% control HeaderObjects %>
            <% if First %>
            <a href="#" class="show">
            <% else %>
            <a href="#">
            <% end_if %>
               <% control Bild %>
                  <% control CroppedImage(579,221) %>
                     <img alt="$Top.Title" width="579px" height="221px" src="$URL" rel="$Top.Top.Beskrivning"/>
                  <% end_control %>
               <% end_control %>
            </a>
         <% end_control %>
         <div class="caption"><div class="content"></div></div>
      </div>
      
      <div class="clear"></div>
      <!-- ============================ End of slider ================================== -->
   </div>
</div>

This doesn't work. Is there another way, have I done wrong somewhere or is it impossible?

Many thanks,
Johan

Avatar
JMagnusson

Community Member, 29 Posts

9 September 2011 at 2:39am

I think that it is impossible this way.
http://www.silverstripe.org/general-questions/show/6366#post258477
Maybe I could do it within the control instead, but I think I remove the description for the slider images instead. That will give me a simplier administration area.

If someone has a better idea maybe you can answere. But I have to do it in another way now.

Thanks. Johan

Avatar
martimiz

Forum Moderator, 1132 Posts

10 September 2011 at 11:47pm

Edited: 10/09/2011 11:48pm

$Top always refers to the absolute top, mostly the (Page)_Controller, not the direct parent control... So, if Beskrivning is a Page property, $Top.Beskrivning would do. As for the Image, instead of using:

<% control CroppedImage(579,221) %>
   <img alt="$Top.Title" width="579px" height="221px" src="$URL" rel="$Top.Top.Beskrivning"/>
<% end_control %>

you could maybe do something like this:

<img alt="$Title" width="579px" height="221px"
src="<% control CroppedImage(579,221) %>$URL<% end_control %>" rel="$Top.Beskrivning" />