Search

Updated to 1.3, thanks Max.

When I don’t supply a display-number param, I get an error message about redefined variables.

This made me look at the code a little bit. I realized that you’re not using param default values

<xsl:param name="pagination-element"/>
<xsl:param name="url"/>
<xsl:param name="display-number"/>
<xsl:param name="next"/>
<xsl:param name="previous"/>

Could be rewritten to

<xsl:param name="pagination-element"/>
<xsl:param name="url"/>
<xsl:param name="display-number" select="'5'" />
<xsl:param name="next" select="'Next &#187;'" />
<xsl:param name="previous" select="'&#171; Previous'" />

That way the optional params will always be set, making tests like

    <xsl:variable name="next-label">
        <xsl:choose>
            <xsl:when test="$next=''">Next &#187;</xsl:when>
            <xsl:otherwise><xsl:value-of select="$next"/></xsl:otherwise>
        </xsl:choose>
    </xsl:variable>

unnecessary.

Nevertheless the problem with the redefined variable display-number still exists. I am not sure but I’ve always tried calling my variables differently from params in order to avoid these problems…

It’s possible to disable next and previous links using call-template?

I imagine something like this:

<xsl:param name="next" select="false()" />
<xsl:param name="previous" select="false()" />

What do you think?

One thing I’ve noticed is that the previous and next items will just loop around. So if you’re on page 1 and you press previous it goes to the last page.

Is there a way to disable it? Or, better yet, is there away to remove the previous link when you’re on the first page and remove the next link when you’re on the last page?

I notice the forum has the same issue on the bottom pagination but not on the top pagination.

It’s always there so that you can do circular navigation should the need arise. However they are given appropriate class attribute values so that you can hide or manipulate visual display if you wish.

True, but it causes issues with a jQuery plugin I’m using. Luckily I was able to get it hide on the last page by fiddling with the code around the 130th line.

I’ve not been looking into the template itself but I get a strange output when viewing the first page:

<ul class="pagination">
  <li class="disabled">
    <a class="pagination-previous" href="http://nilshoerrmann.de/texte/3">Previous</a>
  </li>
  <li class="selected">
    <a class="page" href="http://nilshoerrmann.de/texte/1">1</a>
  </li>
  <li>
    <a class="page" href="http://nilshoerrmann.de/texte/2">2</a>
  </li>
  <li>
    <a class="page" href="http://nilshoerrmann.de/texte/3">3</a>
  </li>
  <li>
    <a class="pagination-next" href="http://nilshoerrmann.de/texte/2">Next</a>
  </li>
</ul>

The first anchor containing the Previous text should not have an href attribute as there are no previous pages.

If you’re on Page 1, then the Previous will link to the last page (page 3) which allows you to do cyclical navigation should you wish. You can disable it with CSS and JS if you need to.

Hm, okay. It would be great if this could disabled via a parameter, though.

Nils, you can go in and edit this yourself directly in the XSLT. If memory serves, it’s towards the end. I ended up changing this as well because I didn’t like there being a Next button when you were on the last page.

Can you post your changes to prevent looping? I’m interested in it myself…

.disabled { display: none; }

;-)

A true perfectionist does not want to have unneeded elements in his markup ;)

And a true pragmatist doesn’t care :)

I know :)

A question out of interest: How is it possible to declare <xsl:variable name="current-page" /> in this template while this is a core Symphony parameter? And doesn’t this declaration interfere with the rest of the site? I’m curious ….

Because it’s local within a template it doesn’t override the global scope (and because it’s a variable and not a parameter). I’ve done this in several Utilities but have since learned the error of my ways. A future version of this XSLT will use different names for clarity.

That makes sense. Thanks, Nick.

Yeah, thanks Nick! I thought it was a mind boggling XSLT change…

I extended this template to fit my needs: http://gist.github.com/408850

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