1770 Posts in 495 Topics by 531 members
Blog Module
SilverStripe Forums » Blog Module » BlogPagination within BlogEntry
Discuss the Blog Module.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 714 Views |
-
BlogPagination within BlogEntry

28 June 2011 at 5:05pm
Hi Carlos and others,
I'm attempting to paginate a blog, then add the navigation and pagination to the BlogEntry template. For this particular client, the BlogHolder redirects to the first child and there is no BlogTree.
I'm not having much joy yet. I've tried wrapping <% control Parent... Top... BlogTree... BlogHolder in the template but I'm not getting any pagination.
I do see that BlogEntry extends Page and BlogPagination is within BlogTree, so I attempted an alternative setup to use BlogTree -> BlogHolder -> BlogEntry, but still was unable to find the right syntax to get the BlogPagination in BlogEntry.
I also tried a function in the model to return getParent->getParent.
Has anyone done this before?
I very much appreciate any advice.
Thanks!
Wilson -
Re: BlogPagination within BlogEntry

15 July 2011 at 12:04pm
Off the top of my head I would guess that in BlogEntry a section like <% control ChildrenOf(/blog/) %> will give you a set of all the children. (assuming the BlogHolder's url is /blog/)
But that won't really get you pagination, just all of them at once.
The template file, BlogPagination, relies on DataObjectSet's NextLink and PrevLink in sophisticated ways.
-
Re: BlogPagination within BlogEntry

27 July 2011 at 12:22am
I am trying to figure this out too. Any ideas?
Thanks in advance..
-
Re: BlogPagination within BlogEntry

27 July 2011 at 2:28am
Turns out BlogEntry extends Page, so you can just treat BlogEntries as pages, i.e. using the PrevNextPage function (that's in another forum post).
public function PrevNextPage($Mode = 'next') {
if($Mode == 'next'){
$Where = "ParentID = ($this->ParentID) AND Sort > ($this->Sort)";
$Sort = "Sort ASC";
} elseif($Mode == 'prev') {
$Where = "ParentID = ($this->ParentID) AND Sort < ($this->Sort)";
$Sort = "Sort DESC";
} else {
return false;
}
return DataObject::get("SiteTree", $Where, $Sort, null, 1);}
| 714 Views | ||
|
Page:
1
|
Go to Top |


