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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

$Up inside a dataobjects loop doesn't work


Go to End


3 Posts   1249 Views

Avatar
Guy Van Bael

Community Member, 61 Posts

11 March 2015 at 10:16pm

Edited: 11/03/2015 10:16pm

Hi,

I have a Projectholder which has projectpages (and photopages) underneath. Each projectpage (and photopage) has a hasmany relation with a dataobject containing an image. When i loop the children and then loop the dataobject, using $Up doesn't display the childpages propertie (adres). If I use $Top.MenuTitle for example it displays the title of the projectholder correctly, but using $Up.MenuTitle (the child's name) doesn't display anything.
Can anybody help me? Here's the code. (i'm trying to add markers to a google map).

$("#map").goMap({
markers: [
<% loop Children %>
{
address: '$Adres',
draggable: false,
html: {
<% if ClassName = ProjectPage %>
<% loop SliderBeelden.limit(1).sort(Sort) %>
content: "<p>$Up.Adres<br/><img src='$Beeld.URL' alt='$Beeld.Name' width='200'></p>",
<% end_loop %>
<% else_if ClassName = FotoPage %>
<% loop FotoPageBeelden.limit(1).sort(Sort) %>
content: "<p>$Up.Adres<br/><img src='$Beeld.URL' alt='$Beeld.Name' width='200'></p>",
<% end_loop %>
<% end_if %>
popup:false
},
id:"$ID"
},
<% end_loop %>

],
maptype: 'ROADMAP' ,
zoom:4,
streetViewControl:true,
icon: 'themes/taxandria/images/taxandria_marker.png'
});
$.goMap.fitBounds()

Avatar
Guy Van Bael

Community Member, 61 Posts

12 March 2015 at 1:54am

Just found a solution.
Instead of $Up, i used $ProjectPage.Adres and $FotoPage.Adres....

All is working now, but i still think it's strange that $Up isn't working.

Avatar
Turismo

Community Member, 28 Posts

27 May 2016 at 10:39am

I had a similar issue with $Up not working, but only as soon as I appended .Sort to my loop. I fixed it by using $Top instead of $Up