3212 Posts in 847 Topics by 809 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1290 Views |
-
forward button - sitetree, not history

20 February 2009 at 2:33am
hi there
I got a wee simple site to create which has got a special navigation: it doesn't have a menu, there are only buttons which you can use for forward and backwards, it should follow the arrangement of the site tree, not the browser history, can you follow me? let's say it's like a little story. I would love to post something into the template and not to link every single button in the cms.
any inputs?
cheers! -
Re: forward button - sitetree, not history

22 February 2009 at 3:12am
You can use the $Sort property to obtain the current position of your page in the sortorder ...
You can then build your previous and next links by getting pages based on their sortorder (currentSort +1 and currentSort -1) ...
Good luck !
-
Re: forward button - sitetree, not history

6 April 2009 at 10:00pm
I wanted this too - here's my solution to it.
In the Page_Controller class I have:
function NextSibling() {
return DataObject::get_one('SiteTree', "ParentID=$this->ParentID and Sort > $this->Sort and Status='Published' and ShowInMenus=1", false, 'Sort asc');
}function PrevSibling() {
return DataObject::get_one('SiteTree', "ParentID=$this->ParentID and Sort < $this->Sort and Status='Published' and ShowInMenus=1", false, 'Sort desc');
}and in the template I have:
<div id="NextPrev">
<% if PrevSibling %>
<a href="$PrevSibling.Link">« Previous Page</a>
<% end_if %><% if NextSibling && PrevSibling %> | <% end_if %>
<% if NextSibling %>
<a href="$NextSibling.Link">Next Page »</a>
<% end_if %>
</div>I don't know if this is the best way to do it, but it works for me.
| 1290 Views | ||
|
Page:
1
|
Go to Top |



