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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Data Model Questions /

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

Up two levels, $Top.Top.Value ?


Go to End


3 Posts   3287 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, 1391 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" />