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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Giving a set a title


Go to End


6 Posts   1103 Views

Avatar
VictorH

Community Member, 29 Posts

14 February 2010 at 8:44am

I want to give each list of posters that gets generated a unique rel tag. So the first list of posters will have something like rel="movie-1" and then the second list of posters has rel="movie-2" like this code. Is there a way to give a DataObjectManager a Title or something?

<ul>
  <li><a rel="set-1">item 1</a></li>
  <li><a rel="set-1">item 2</a></li>
</u>

<ul>
  <li><a rel="set-2">item 2</a></li>
  <li><a rel="set-2">Item 4</a></li>
</ul>

<% control Children(4) %>
	<h3><a href="$Link">$Title</a></h3>
	<h4>Sypnosis</h4>
	<p>$Content</p>
	
	<h4>Posters</h4>
	<% if Posters %>
		<ul class="posters clear">
			<% control Posters %>
				<li>
					<a href="<% control PosterImage %>$URL<% end_control %>" title="$PosterName" rel=""><% control PosterImage %><% control CroppedImage(125,188) %><img src="$URL" alt="$PosterName" /><% end_control %><% end_control %><span></span></a>
				</li>
			<% end_control %>
		</ul>
	<% else %>
		<h5>No Posters Yet</h5>
		<p>Do you have a poster for this movie? Please <a href="contact">send it to us</a> so we can add it to the site.</p>
	<% end_if %>
<% end_control %>

Avatar
UncleCheese

Forum Moderator, 4102 Posts

14 February 2010 at 9:50am

There are a number of ways to do it.

rel="movie-$Pos" will give you the number of the record's position. Starts with 1.

Or, since you know the ID is guaranteed unique, you can always do

rel="movie-$ID"

Avatar
VictorH

Community Member, 29 Posts

14 February 2010 at 9:54am

That would generate something like this.

<ul>
  <li><a rel="movie-1">item-1</a></li>
  <li><a rel="movie-2">item-2</a></li>
  <li><a rel="movie-3">item-3</a></li>
</ul>

<ul>
  <li><a rel="movie-1">item-1</a></li>
  <li><a rel="movie-2">item-2</a></li>
  <li><a rel="movie-3">item-3</a></li>
</ul>

I want to generate something like this.

<ul>
  <li><a rel="movie-1">item-1</a></li>
  <li><a rel="movie-1">item-2</a></li>
  <li><a rel="movie-1">item-3</a></li>
</ul>

<ul>
  <li><a rel="movie-2">item-1</a></li>
  <li><a rel="movie-2">item-2</a></li>
  <li><a rel="movie-2">item-3</a></li>
</ul>

Avatar
UncleCheese

Forum Moderator, 4102 Posts

14 February 2010 at 10:17am

What about rel="movie-$ParentID"?

Avatar
VictorH

Community Member, 29 Posts

14 February 2010 at 10:23am

Just tried it. It doesn't generate anything just rel="movie-"

Avatar
UncleCheese

Forum Moderator, 4102 Posts

14 February 2010 at 10:45am

Well, you get the idea, though. It's just the foreign key that ties the object to the parent. So whatever your has_one relationship is from Poster to its containing page, use that, e.g. $PosterHolderID, or whatever you're using.