Jump to:

7938 Posts in 1541 Topics by 945 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Giving a set a title

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 718 Views
  • VictorH
    Avatar
    Community Member
    29 Posts

    Giving a set a title Link to this post

    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 %>

  • UncleCheese
    Avatar
    4085 Posts

    Re: Giving a set a title Link to this post

    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"

  • VictorH
    Avatar
    Community Member
    29 Posts

    Re: Giving a set a title Link to this post

    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>

  • UncleCheese
    Avatar
    4085 Posts

    Re: Giving a set a title Link to this post

    What about rel="movie-$ParentID"?

  • VictorH
    Avatar
    Community Member
    29 Posts

    Re: Giving a set a title Link to this post

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

  • UncleCheese
    Avatar
    4085 Posts

    Re: Giving a set a title Link to this post

    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.

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