Search

Hi,

I want to create a pagination on a specific article’s page with links to Next Article and Previous Article. I’m using two data-sources one for Article Page that fetch all entries and another that filters by the article’s title.

What’s the better way to do this kind of pagination?

Thanks.

I believe someone had a solution for this worked out. Will see if I can dig it up.

A few existing threads that might explain some more:

DS Filtering: next article / previous article — quite an old thread with an earlier version of Symphony. Skip to the second page and see the idea about using dates. You could use a date field as the Output Parameter from the Articles DS, and use two additional data sources to use this parameter and get the next article after this date (one ordered Asc, one Desc, limiting to 1). It’s not ideal, but prevents the need to include all articles.

Link to next position in a datasource is probably what you’re doing now — including all articles, looking for the current ID in the nodeset and then selecting the next. So long as your DS isn’t too large this should be a satisfactory method.

Simple Symphony Question some more explanation of using XPath axes to select next/previous sibling elements.

This has come up a few times, so perhaps there should be a dedicated tutorial towards achieving this.

I have a problem with this, but it’s still better than pulling all the entries. See it here: http://getsymphony.com/forum/discussions/832/ Basically, you have to pull the next 2 entries instead of 1 because it includes the current entry in the DS. I haven’t been able to test in the latest release, so it may work correctly now.

What you have to do is what nickdunn says above, have three datasources.

  • One that outputs a pramater of the current entry’s date with a pram of $ds-article-main,
  • one that pulls 1 entry before the current entry with the date field earlier than {$ds-article-main},
  • and one that pulls 1 entry after the current entry with the date field later than {$ds-article-main}.

The date field allows for the filtering syntax of earlier than and later than. You could also pick a really old and really far away date like 01-01-1980 and 01-01-2030 to filter with instead. (Not sure what dates are too far back/forward for unix time.)

And there it is :) Thanks, Nick.

And another way of achieving this: Relative Pagination: Previous and Next Links — this uses the same idea as above whereby the first Data Source uses an Output Parameter, this time a sort number (from the Order Entries extension) rather than a date.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details