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

Showing all children from the root


Go to End


3 Posts   1002 Views

Avatar
borriej

Community Member, 267 Posts

10 August 2010 at 1:51am

Edited: 10/08/2010 1:51am

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

Forum Moderator, 4102 Posts

10 August 2010 at 2:50am

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

Community Member, 267 Posts

10 August 2010 at 3:07am

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