Search

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=$')"/>
</xsl:call-template>

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 http://pfiff.designbits.de/publikationen/flyer?p=1

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"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml"
    doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
    omit-xml-declaration="yes"
    encoding="UTF-8"
    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"/>
    </div>

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

</xsl:template>
</xsl:stylesheet>

and my XML:

<?xml version="1.0" encoding="utf-8" ?>
<data>
    <params>
        <today>2011-07-18</today>
        <current-time>15:12</current-time>
        <this-year>2011</this-year>
        <this-month>07</this-month>
        <this-day>18</this-day>
        <timezone>+01:00</timezone>
        <website-name>Myriago</website-name>
        <page-title>blog</page-title>
        <root>http://www.lukasgladki.co.uk/symphony</root>
        <workspace>http://www.lukasgladki.co.uk/symphony/workspace</workspace>
        <root-page>blog</root-page>
        <current-page>blog</current-page>
        <current-page-id>78</current-page-id>
        <current-path>/blog/?debug&amp;symphony-page=blog/</current-path>
        <parent-path>/</parent-path>
        <current-url>http://www.lukasgladki.co.uk/symphony/blog/?debug&amp;symphony-page=blog/</current-url>
        <upload-limit>5242880</upload-limit>
        <symphony-version>2.2.1</symphony-version>
        <page />
        <cookie-username>lukigi</cookie-username>
        <cookie-pass>f81b6cee5718424b2381e490d2063df9a1747bd3</cookie-pass>
        <site-mode>live</site-mode>
        <ds-generalsettingsds>
            <item handle="symphonycms">symphonycms</item>
        </ds-generalsettingsds>
    </params>
    <events>
        <login-info logged-in="true" id="1" user-type="developer" primary-account="yes">
            <name>Lukasz Gladki</name>
            <username>lukigi</username>
            <email>lukigi@gmail.com</email>
            <default-area type="page" />
        </login-info>
    </events>
    <generalsettingsds>
        <section id="10" handle="preferences">Preferences</section>
        <entry id="87">
            <menu-background-color>#</menu-background-color>
            <header-background-color>#</header-background-color>
            <body-background-color>#4b6251</body-background-color>
            <captions-color>#</captions-color>
            <menu-text-color>#</menu-text-color>
            <menu-text-hover-color>#</menu-text-hover-color>
            <paragraph-color>#f1f3f2</paragraph-color>
            <twitter-username-for-displaying-tweets-on-homepage handle="symphonycms">symphonycms</twitter-username-for-displaying-tweets-on-homepage>
            <website-title-color>#</website-title-color>
            <website-title-webfont>
                <item handle="radley">Radley</item>
            </website-title-webfont>
            <website-title-fontsize>
                <item handle="55px">55px</item>
            </website-title-fontsize>
        </entry>
    </generalsettingsds>
    <navds>
        <section id="7" handle="pages">Pages</section>
        <entry id="162">
            <sort><span class="order">1</span></sort>
            <title handle="home">Home</title>
        </entry>
    </navds>
    <news-data>
        <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>
        <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>
        </entry>
    </news-data>
</data>

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.

@qur2

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

Thanks.

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:

<!--
    PAGINATION RESULTS
    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.
        </p>
    </xsl:for-each>
</xsl:template>

<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:choose>
            <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:choose>
    </xsl:param>
    <xsl:value-of select="$first-result" />
    <xsl:text> - </xsl:text>
    <xsl:value-of select="$last-result" />
</xsl:template>

This can be called like so:

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

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.
</p>

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.

Hello,

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/$'" />
    </xsl:call-template>

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?

Page

Debug..

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/$')" />
    </xsl:call-template>

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 www.domain.com/symphony/2 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