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:
- The first page link will not have the limit and limitstart numbers added to them.
- 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”