antknight Posted May 4, 2013 Share Posted May 4, 2013 I would like to get all the child pages of the news-month-archive template sort them by -news_date and limit to 10 per page. This is what I have at the moment: <?php $results = $pages->find("template=news-item, sort=-news_date, limit=10"); $pagination = $results->renderPager(array( 'numPageLinks' => "5", 'nextItemLabel' => "Next", 'previousItemLabel' => "Prev", 'listMarkup' => "<ul class='MarkupPagerNav'>{out}</ul>", 'itemMarkup' => "<li class='{class}'>{out}</li>", 'linkMarkup' => "<a href='{url}'><span>{out}</span></a>")); echo "<ul class='list'>"; foreach($results as $result) { echo "<li class='list-item'>"; echo "<section>"; echo "<h5><a href='{$result->url}'>{$result->title}</a></h5>"; echo "<em>{$result->news_date}</em>"; if($result->body) { $summary = substr($result->body, 0, 150); if(($pos = strrpos($summary, ".")) !== false) { $summary = substr($summary, 0, $pos); }; echo "<p>{$summary} <a href='{$result->url}'>...more</a></p>"; } echo "</section>"; } echo "</ul>"; echo $pagination; ?> How can I rewrite the selector to achieve this? I tried $results = $pages->find("template=news-month-archive")->children("sort=-news_date, limit=10"); but I get a server error? Many Thanks Link to comment Share on other sites More sharing options...
diogo Posted May 4, 2013 Share Posted May 4, 2013 The result of the find is an array, so you can't get the children of it. If there's only one page with that template you can do: $results = $pages->get("template=news-month-archive")->children("sort=-news_date, limit=10"); 4 Link to comment Share on other sites More sharing options...
antknight Posted May 4, 2013 Author Share Posted May 4, 2013 Arrrgghhh it's always the little things that trip me up. Thanks diogo Link to comment Share on other sites More sharing options...
antknight Posted May 5, 2013 Author Share Posted May 5, 2013 So there are two selectors I need: One to grab all pages that are children of the news-month-archive template site wide. One to grab all pages that are children of the news-month-archive template in the current rootParent Anybody help me out? Link to comment Share on other sites More sharing options...
ryan Posted May 7, 2013 Share Posted May 7, 2013 One to grab all pages that are children of the news-month-archive template site wide. $pages->find("parent.template=news-month-archive"); One to grab all pages that are children of the news-month-archive template in the current rootParent $page->rootParent->find("parent.template=news-month-archive"); 6 Link to comment Share on other sites More sharing options...
antknight Posted May 8, 2013 Author Share Posted May 8, 2013 parent.template......interesting! Thanks Link to comment Share on other sites More sharing options...
Macaco Posted August 10, 2019 Share Posted August 10, 2019 Hi guys, I'm having a problem with multiple-languages. I want to make a list of all the children of one page even if the title field has been only populated in one of the languages, yet the link should point to the page in the currently selected language. Didn't figure out yet :(.... Link to comment Share on other sites More sharing options...
dragan Posted August 10, 2019 Share Posted August 10, 2019 Well, there are two things to watch out for: Is the page activated in the alt. language? How is the title-field configured in the alt. lang. page version? At field-level, you can define the behaviour of what's shown, in the details-tab: If you use the option shown above, you still have to make sure the alt. lang. page version is activated. Link to comment Share on other sites More sharing options...
Macaco Posted August 10, 2019 Share Posted August 10, 2019 Hi Dragan, I started working from the multi-language profile. the field is "Title (multi-language)" and it has "Inherit value from default language" on. Although the page's children can be created from another page using a field (page reference). which seems to only populate the english field. 27 minutes ago, dragan said: alt. lang. page version is activated I'm not sure I understand the alt lang version. Link to comment Share on other sites More sharing options...
dragan Posted August 10, 2019 Share Posted August 10, 2019 1 hour ago, Macaco said: I'm not sure I understand the alt lang version. I mean this: note the "active" checkboxes. 1 hour ago, Macaco said: Although the page's children can be created from another page using a field (page reference). which seems to only populate the english field. OK, now I know a bit better what you mean. These pages are not created "manually" in the admin, but from a page-reference field that has the option "allow to create new pages?" in the field settings. If that is indeed the case, I wouldn't know what the expected / default behavior would be. Only create the page in the default language? (which seems to be the case). I don't know if that is configurable. I don't have time right now to investigate - maybe you'd have to use a hook to automatically activate all languages when creating a new page like that. 1 Link to comment Share on other sites More sharing options...
Macaco Posted August 10, 2019 Share Posted August 10, 2019 Ah! You are right, when I create a new page"manually", it comes as "active" by default. But when the page is created from page-reference it doesn't. I'm gonna look into the hook. Thank you Dragan, PS. apologies for using the wrong thread, I guess it should be in multi-language. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now