Jump to:

3460 Posts in 1064 Topics by 739 members

Data Model Questions

SilverStripe Forums » Data Model Questions » control ImageResources, how to return ImageResources in groups of 5

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

Page: 1
Go to End
Author Topic: 546 Views
  • DsX
    Avatar
    Community Member
    178 Posts

    control ImageResources, how to return ImageResources in groups of 5 Link to this post

    Ok, I am working on a basic gallery.

    I have a galleryholder, gallerypage, and the gallerypage has many ImageResources
    when in the gallerypage.ss how can I control through the ImageResources but have groups of 5 ImageResources returned until all are returned? Or until a set number are returned?

    I need to wrap every 5 in a div tag for use in a scroller.
    the post here: http://www.silverstripe.org/data-model-questions/show/4871
    explains my issue very well except for he had control over the number of segments. I may need two divs or 10.
    So having a method for each isn't working (a have done this for a latestgalleries feature, since I know I have a minimum amount of data I am just calling the last 10 galleries).

    I have found information on pagination thats going in the right direction, but I haven't been able to make the jump to getting a version to work for my purposes.

  • DsX
    Avatar
    Community Member
    178 Posts

    Re: control ImageResources, how to return ImageResources in groups of 5 Link to this post

    Ok the approach I think I would like to take is:

    1: create a method (getGalleryGroupData) that can get my dataobjects (DataObject::get) and then setup and array to be returned as a dataobject so that I can loop through it in a control in the template. The array should contain 1 set of data for every group (the number of items it the group should be set by passed int) the data will simply be the limit points for querying this data.

    2: a second method (getGalleryGroup) that takes two parameters and queries the for a dataobjectset and returns it.

    so I should be able to use it like such in the template:

    <% control GalleryGroupData %>
    <div class="gallerygroup">
    <% control GalleryGroup(startpoint,endpoint) %>
    <img src="$galleryThumbnailURL">
    $galleryDescription
    <% end_control %>
    <div/>
    <% end_control %>

    So I have the second method working already... I am lost in how I can gather the necessary information from the first dataobjectset and return it so that I can control through it.

  • DsX
    Avatar
    Community Member
    178 Posts

    Re: control ImageResources, how to return ImageResources in groups of 5 Link to this post

    OK, played around and now know that I can't pass parameters from a template as variables.

    I have a solution, will try to clean it up and get it posted.

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