fishme
April 10, 2015, 1:31pm
1
Hi,
my structure looks like that:
wonderful-world
-> folder
-> locations
-> folder
- usw…
amazing-world
strange-world
template:
What I want todo is, to get all pages with a specific template inside from one of the root folders.
$site->index()->filterBy('template','locations');
That works, but with that I got the locations from every root folder.
so like that…
$page(‘wonderful-world’)->children()->filterBy(‘template’,‘locations’);
but that search just in one level.
I hope it is clear what I mean with that, thank you for your help.
1 Like
Luke
April 10, 2015, 1:38pm
2
Try
$pages->find('wonderful-world')->children()->filterBy('template','locations');
There’s also “intendedTemplate” which comes in handy if you name a content .txt file one thing, but the template/blueprint files don’t exist. So if there was no ‘locations.php’ template, it “template” would be “default” but intendedTemplate would be “locations”.
http://getkirby.com/docs/cheatsheet
1 Like
fishme
April 10, 2015, 1:59pm
3
thanks for your quick answer but, does’t work
page('wonderful-world')->index()->filterBy(…)
http://getkirby.com/docs/cheatsheet/page/index
1 Like
Luke
April 10, 2015, 2:24pm
5
It appears @distantnative has a solution as well. As for the one I presented, I’m not sure why it didn’t work for you.
I tried this both ways and it worked fine.
<?php
$locations = page('home')->index()->filterBy('intendedTemplate','_section');
foreach($locations as $location):
echo "Location = " . $location->title();
endforeach;
?>
<?php
$locations = $pages->find('home')->children()->filterBy('intendedTemplate','_section');
foreach($locations as $location):
echo "Location = " . $location->title();
endforeach;
?>
1 Like
fishme
April 10, 2015, 2:55pm
6
works works!!! yeah thanks was my mistake