Hello everybody,

I have a long list of publications that works great using the pagination template, especially within categories.

When no category is set in the URL I get a very ugly URL though, with two consecutive forward slashes. Is there any way to circumvent this? This is my code:

<xsl:call-template name="pagination">
<xsl:with-param name="pagination" select="/data/publikationen/pagination" />
<xsl:with-param name="display-number" select="'2'" />
<xsl:with-param name="pagination-url" select="concat($root, '/publikationen/', $cat, '/?p=$')"/>

Thanks for any help.

Have you tried removing the '/' in the GET param

<xsl:with-param name="pagination-url" select="concat($root, '/publikationen/', $cat, '?p=$')"/>

It works for me.. and when you do have a category, it should also work without the '/' no?

When I go to this url

I think the system (possible the .htaccess rules) automatically add the forward slash into the last url param for you.

Hi Andrew,

Awesome, thanks. I was so sure I had tried that before but it seems that I hadn't. You are right, the slash is automatically added and it works like a charm now.

Hi guys, I'm having really bad time implementing this. I'm new to Symphony and XSLT so I'm probably making some basic mistake here, but I'm stuck and need help.

I've tried implementing pagination but got the following error:

XSLTProcessor::transformToXml(): Invalid type XSLTProcessor::transformToXml(): xmlXPathCompiledEval: 1 objects left on the stack.

my xsl:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"

<xsl:output method="xml"
    doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
    indent="yes" />
    <xsl:include href="../utilities/master.xsl"/>
    <xsl:include href="../utilities/get-news.xsl"/>
    <xsl:include href="../utilities/pagination.xsl"/>

<xsl:template match="data">
    <div id="content">          
       <xsl:apply-templates select="news-data"/>

     <xsl:call-template name="pagination">
       <xsl:with-param name="pagination-element" select="news-data/pagination" />
       <xsl:with-param name="url" select="'/blog/$'" />


and my XML:

<?xml version="1.0" encoding="utf-8" ?>
        <page />
            <item handle="symphonycms">symphonycms</item>
        <login-info logged-in="true" id="1" user-type="developer" primary-account="yes">
            <name>Lukasz Gladki</name>
            <default-area type="page" />
        <section id="10" handle="preferences">Preferences</section>
        <entry id="87">
            <twitter-username-for-displaying-tweets-on-homepage handle="symphonycms">symphonycms</twitter-username-for-displaying-tweets-on-homepage>
                <item handle="radley">Radley</item>
                <item handle="55px">55px</item>
        <section id="7" handle="pages">Pages</section>
        <entry id="162">
            <sort><span class="order">1</span></sort>
            <title handle="home">Home</title>
        <pagination total-entries="3" total-pages="2" entries-per-page="2" current-page="1" />
        <section id="13" handle="news-entry">News entry</section>
        <entry id="168">
            <date time="20:38" weekday="4">2011-07-14</date>
            <title handle="3rd-entry-on-this-blog">3rd entry on this blog</title>
            <content mode="formatted"><p>Its getting slightly better now, but still plenty to learn</p></content>
        <entry id="166">
            <date time="16:39" weekday="4">2011-07-14</date>
            <title handle="hello-world">Hello world</title>
            <content mode="formatted"><p>Lorem ipsum donor sit amet</p></content>

ahh nvm, found the solution in this thread, I've used old parameter name pagination-element instead of just pagination

I just finished my pagination setup and I thought I'd share it. Basically, it is used to paginate records that can be filtered by source or by source type. What I did is building a pagination-url that recalls of every URL param while updating or adding the url-page.

Since that could be useful, feel free to check the gist. qur2.


Good stuff. Can you please post the code on this thread? It would be a collection of XSLT small stuff.


I was wondering whether it would be worth adding an option to display the number of results and pages. I added the following templates to the pagination utility:

    Display number of results and pages returned
<xsl:template name="pagination-results">
    <xsl:param name="pagination" />
    <xsl:for-each select="$pagination[@total-pages &gt; 1]">
        <p>Displaying <b><xsl:call-template name="pagination-results-range" /></b> of a total of <b><xsl:value-of select="@total-entries" /></b> results.
            <b>Page <xsl:value-of select="@current-page" /></b>
            <xsl:text> of </xsl:text>
            <xsl:value-of select="@total-pages" /> pages.

<xsl:template name="pagination-results-range">
    <xsl:param name="first-result" select="@current-page * @entries-per-page - @entries-per-page + 1" />
    <xsl:param name="last-result">
            <xsl:when test="@current-page = @total-pages"><xsl:value-of select="@total-entries" /></xsl:when>
            <xsl:otherwise><xsl:value-of select="@current-page * @entries-per-page" /></xsl:otherwise>
    <xsl:value-of select="$first-result" />
    <xsl:text> - </xsl:text>
    <xsl:value-of select="$last-result" />

This can be called like so:

<xsl:call-template name="pagination-results">
    <xsl:with-param name="pagination" select="/data/section-name/pagination" />

And the resulting output would be something like:

<p>Displaying <b>312 - 331</b> of a total of <b>331</b> results.
    <b>Page 17</b> of 17 pages.

Or something like this:

Displaying 312 - 331 of a total of 331 results. Page 17 of 17 pages.

Edit: Fixed some math on $first-result.

How would you set a url parameter for pagination number?

Sorry. I've figured it out eventually.


Only i who have problem with "growing" urls?

First pagination works good, next one links to /tweets/2/3

In other words, it adds both the current and next page's 'folder'.

My xsl:

<xsl:call-template name="pagination">
        <xsl:with-param name="pagination" select="/data/tweets-test/pagination" />
        <xsl:with-param name="display-number" select="'7'" />
        <xsl:with-param name="url" select="'/tweets/$'" />

And XML:

<tweets-test> <pagination total-entries="69" total-pages="23" entries-per-page="3" current-page="2" />

page is an url-parameter to /tweets and in the data source i entered {$page} as "return page"...

Ping ;)

That's weird, it should work that way. You could however try

<xsl:with-param name="url" select="concat($root,'/tweets/$/')" />

Didn't work :/

The page i'm testing on is here if that is to any help?



I believe the param is called pagination-url and not just url. So

    <xsl:with-param name="pagination-url" select="'/tweets/$/'" />

should work. I also appended a / to the parameter, because Symphony redirects every URL without trailing slash to one with one. (And you have to be logged in to be able to see the debug page for security reasons.)

Thanks @klaftertief, must'v copied from some old example!

I have difficulty getting this wonderful utility to work on "home.xsl"

<xsl:call-template name="pagination">
      <xsl:with-param name="pagination" select="/data/homepage-articles/pagination" />
      <xsl:with-param name="display-number" select="'7'" />
      <xsl:with-param name="pagination-url" select="concat($root, '/data/articles/$')" />

Installed Symphony 2.2.5 and load the home page, adding more dummy articles so I have a total of 7 which is 2 pages.

Add "pagination.xsl" utility and add the above code to "home.xsl", I can see pagination is appear on the home page but the links will produce 404 page, how do I go from here? Do I need to modify homepage-article component?

This utility is purely for creating the pagination hyperlinks in your HTML. You still need to configure your page to accept a URL parameter containing the page number, and configure your data source to enable pagination and use this parameter as the page number. Example.

Got it right by adding "url-" to the {$url-p}! Woot, took me 2 days to try out all the combination.

Do bear with me for anther question after reading all the questions but I still haven't got the idea which work which not. Hopfully, I wish to use this SEO friendly format instead of ?p=2 for page 2. How would I go about it? Do I need to edit the template?

My homepage-articles data source look like this: Limiting to: 5 Return page: {$url-p} Required URL Param: (none) <- When do we use this field for which scenario?

by the way I read one of your comment which contain article/:page is :page an example or a code?

Please guide me.

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