Joomla 1.0.x page break (mospagebreak) with SEF

Joomla’s venerable {mospagebreak} tag should work for breaking articles into multiple-pages … but doesn’t work with SEF URLs on my install. Here is how I fixed it.

So I have SEF URLs (Joomla’s built-in SEF) turned on. And the {mospagebreak} tag does split the articles, but for some reason, URLs such as /content/view/id/limit/limitstart – such as /content/view/123/1/1/ – do not work.

So I peeked into the JOOMLA_DIR/includes/sef.php and found the problem. All changes are in the sefRelToAbs() function.

Here is what I changed:

Approximately line 450 or so, make sure we don’t check for the upper bound of Itemid and check instead of non-zero (non-firstpage) limitstart numbers:

// Itemid
if ( isset( $parts['Itemid'] ) ) {
  //only add Itemid value if it does not correspond with the 'unassigned' Itemid value
  if ( $parts['Itemid'] != 99999999 && $parts['Itemid'] != 0 ) {
    $sefstring .= $parts['Itemid'].'/';
  }
}

to:

// Itemid
if ( isset( $parts['Itemid'] ) ) {
  //only add Itemid value if it does not correspond with the 'unassigned' Itemid value
  if ( $parts['limitstart'] != 0 && $parts['Itemid'] != 0 ) {
    $sefstring .= $parts['Itemid'].'/';
  }
}

Approximately line 460 or so, add a check for non-zero (non-firstpage) “limitstart”, so around these lines:

// limit
if ( isset( $parts['limit'] ) ) {
$sefstring .= $parts['limit'].'/';
}
// limitstart
if ( isset( $parts['limitstart'] ) ) {
$sefstring .= $parts['limitstart'].'/';
}

add this:

// Check for limitstart
if ( $parts['limitstart'] != 0 ) {
...
} // END CHECK FOR limitstart

so the whole thing looks like:

// check for limitstart
if ( $parts['limitstart'] != 0 ) {
// limit
if ( isset( $parts['limit'] ) ) {
$sefstring .= $parts['limit'].'/';
}
// limitstart
if ( isset( $parts['limitstart'] ) ) {
$sefstring .= $parts['limitstart'].'/';
}
} // END CHECK FOR limitstart

And it should work!

Of course, the URLs will be changed slightly, there will be two changes you will notice:

  1. The first page link will not have the limit and limitstart numbers added to them.
  2. Second and more pages have an additional “99999999″ Itemid value added – but that’s needed for them to work.

0 Responses to “Joomla 1.0.x page break (mospagebreak) with SEF”



  1. No Comments Yet

Leave a Reply




Blog Stats

  • 5,919 hits

My Work Blog

This is my code blog, where I post any interesting code I develop during the course of my work. My research blog is on Blogger, and that is where I update the course of my research work at Columbia University. Blogger's source code formatting is not up to par, but Wordpress' is excellent, which is why my code is being posted on this blog.