Jump to:

7935 Posts in 1536 Topics by 943 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Showing all children from the root

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: 646 Views
  • borriej
    Avatar
    Community Member
    267 Posts

    Showing all children from the root Link to this post

    Hello,

    I got the following structure:

    1) Home (page.ss)
    2) Portfolio (PagePortfolioHolder.ss)
    - Catagory 1 (PagePortfolioGroup.ss)
    -> Item 1 (PagePortfolio.ss)
    -> Item 2 (PagePortfolio.ss)
    -> Item 3 (PagePortfolio.ss)

    - Catagory 2 (PagePortfolioGroup.ss)
    -> Item 1 (PagePortfolio.ss)
    -> Item 2 (PagePortfolio.ss)
    -> Item 3 (PagePortfolio.ss)

    - Catagory 3 (PagePortfolioGroup.ss)
    -> Item 1 (PagePortfolio.ss)
    -> Item 2 (PagePortfolio.ss)
    -> Item 3 (PagePortfolio.ss)

    Now the trick is:
    I want to the children of the Catagory 1, 2 & 3 to be shown on the Portfolio (PagePortfolioHolder.ss)

    I have created something like this:

    class Page_Controller extends ContentController {

       function PortfolioCases($num=999) {
        $portfolio = DataObject::get_one("PagePortfolioGroup");
        return ($portfolio) ? DataObject::get("PagePortfolio", "ParentID = $portfolio->ID", "Date DESC", "", $num) : false;
       }

    and in the template (PagePortfolioHolder.ss)

                <% control PortfolioCases %>
                   <div id="CaseHolder" class="$ClassName" >
                   
                      <div id="CaseThumbHolder">
                         <div id="CaseThumb" style="background-image:url('$Thumbnail.url')">
                         </div>
                      </div>
                      
                      <div id="CaseTextHolder">
                         <div id="CaseText">
                            <h2>$Title</h2>
                            <p>$Content.LimitWordCount(40)</p>
                         </div>
                         <div id="CaseButton">
                            <div id="button_bekijk" OnClick="javascript: window.location = '$Link';" style="cursor: pointer">
                            </div>
                         </div>
                      </div>
                   
                   </div>
                <% end_control %>

    But it only prints the children of the FIRST catagory.

    Why? And how can I fix it so it will print all childeren of all subcatagories?

    Thank you!

  • UncleCheese
    Avatar
    4085 Posts

    Re: Showing all children from the root Link to this post

    I'd love to help you, but before I go any further, I need to know what in God's name happened here:

    <div id="button_bekijk" OnClick="javascript: window.location = '$Link';" style="cursor: pointer">

    ?!?!?!?!?!?!?!

  • borriej
    Avatar
    Community Member
    267 Posts

    Re: Showing all children from the root Link to this post

    hehe, I confess: i did that

    I wanted the divs to have a hover effect and i want the divs to be clickable.

    Got the solution:

       function PortfolioCases($num=999) {
        return DataObject::get("PagePortfolio", "", "Date DESC", "", $num);
       }

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