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.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

Move through page siblings


Go to End


2 Posts   1603 Views

Avatar
Blackdog

Community Member, 156 Posts

7 August 2008 at 4:02pm

Hello everyone,

just working away on a site and it has controls for the user to move forward and back throgh the page siblings. I took a look at the sibling control posted in the doku but that will list all siblings.

Is there any way to identify the current page and using that as the offset? This could allow for the query to be limited to 1 and the offset set to pickup the next/previous page only.

cheers.

Avatar
Blackdog

Community Member, 156 Posts

7 August 2008 at 4:20pm

Ok, probably the best thing to do is count the rows up until the item ID then use that as the offset. Right?

$sqlQuery = new SQLQuery(
"COUNT(ItemName.ID)",
"ItemName WHERE ItemName.ID < ".$this->ID.""
);

echo $sqlQuery->execute()->value();