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.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Showing all children from the root


Reply

3 Posts   669 Views

Avatar
borriej

10 August 2010 at 1:51am (Last edited: 10 August 2010 1:51am), Community Member, 267 Posts

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!

Avatar
UncleCheese

10 August 2010 at 2:50am 4085 Posts

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

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

Avatar
borriej

10 August 2010 at 3:07am Community Member, 267 Posts

hehe, I confess: i did that :P

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);
   }