pagebreak doesn't work correct if using JCE

By changing the editor TinyMCE to JCE problems came up with inserting pagebreaks in articles.
No contentheading headlines will be displayed when pagebreak was inserted by JCE.


This is NOT caused by JCE it is caused by line 112 in <Joomla>/plugins/content/pagebreak.php, which is wrong
instead of

112: $attrs = JUtility::parseAttributes($matches[$page-1][1]);

it should read

112: $attrs = JUtility::parseAttributes($matches[$page-1][0]);

Further details see below.


For a pagebreak the editors insert an <hr> - tag with class="system-pagebreak" and optional the attributes title and alt for the headline and ToC respectively.

The contentpart of an article will be rendered at top with a <h1 class="componentheading"> which consists of the articles title and after that an <h2 class="contentheading"> which consists of the articles title completed by the page-title given in the <hr>-tag. And this <h2> element will only be displayed, wenn the <h1> element != <h2> element.

In all my articles made by TinyMCE all works fine but in articles with pagebreaks made by JCE no contentheading (<h2>) will be displayed. And in articles, generated by TinyMCE and modified by JCE all TinyMCE-pagebreaks are fine, all JCE's aren't displayed.

All other issues with pagebreak like ToC, pagenumbering etc work fine.

The reason:

TinyMCE inserts a pagebreak like <hr title="xyz" alt="uvw" class="system-pagebreak" /> while JCE will insert <hr class="system-pagebreak" title="JCE-Titel" alt="JCE-ToC" /> same content other sequence, whereas JCE it does "better" according to the rules, given e.g. in <Joomla>/plugins/content/pagebreak.php, line 20ff:
* Page break plugin
* <b>Usage:</b>
* <code><hr class="system-pagebreak" /></code>
* <code><hr class="system-pagebreak" title="The page title" /></code>
* or
* <code><hr class="system-pagebreak" alt="The first page" /></code>
* or
* <code><hr class="system-pagebreak" title="The page title" alt="The first page" /></code>
* or
* <code><hr class="system-pagebreak" alt="The first page" title="The page title" /></code>

The pagebreak.php looks for pagebreaks with

36: $regex = '#<hr([^>]*?)class=(\"|\')system-pagebreak(\"|\')([^>]*?)\/*>#iU';

74: $matches = array();
75: preg_match_all( $regex, $row->text, $matches, PREG_SET_ORDER );

which gives the array $matches with all pagebreaks. Each pagebreakitem is an array of 5 Elements, item[0] holds the complete result (i.e. <hr............/>) item[1]..item[4] are holding the subpattern found in the matched text, whereas item[1] holds the part between "<hr" and "class=" and item{4] holds the part between "sytem-pagebreak" plus ' or " and "/>". the other both will have ' or ".

So in my opinion only item[0] shoud be used for all further steps because all others are depending on the sequence of class-definition and attributes.

Unfortunately, on line 112 the attributes (title and alt) will be extracted by

112: $attrs = JUtility::parseAttributes($matches[$page-1][1]);

which means item[1], which in case of classdefinition first is an empty string, only with classdefinition last (the TinyMCE-way) item[1] will hold title and alt

therefore shoud read

112: $attrs = JUtility::parseAttributes($matches[$page-1][0]);

and all works fine.

Opened On:
12 Jan 2009, 10:01 by Ralf-Michael Stach
Closed On:
8 Mar 2009, 15:14
Fixed in SVN

Filed Under

  • User


Posted on 12 Jan 2009, 17:19 by Elin Waring
Have you discussed this on the JCE forums? What do they say?
Posted on 12 Jan 2009, 17:46 by Ralf-Michael Stach
No. I didn't because it is definitely not a JCE problem, JCE was only the trigger to start my analysis. You can have the same result adding a pagebreak in an article "by hand" like <hr class="system-break" title="somewhat" alt="something" />. Every pagebreak where the part [class="system-break"] is followed by the part [title="....] will fail.

The problem is caused by the in my opinion wrong use of $matches[x][1] instead of $matches[x][0]
Posted on 13 Jan 2009, 9:58 by Klas Berlič
I can confirm that.

<hr title="test title" alt="tesalias" class="system-pagebreak" />

works ok


<hr class="system-pagebreak" title="page title test 2" alt="test2" />


According to notes in pagebreak.php second way is the right way (so JCE is just following the notes). Either this notes or the way pagebreak works should be corrected - in any case this is a bug.

I also tested suggested change and I can confirm it fixed the problem - after the change it works ok with both ways of doing it (mce and jce). Patch is attached.

Posted on 2 Mar 2009, 10:43 by Gergo Erdosi
Moving to Pending, because we have a patch. Just a note, #15300 and #14558 also modifies pagebreak.php, so it's possible that there will be conflicts.
Posted on 7 Mar 2009, 15:34 by Mark Dexter
I cannot reproduce this issue. Here is what I did.
1. Changed to No Editor.
2. Created an article as follows:

<p>This is a test of the page break issue. </p><p>This is a test of the page break issue. </p><hr id="system-readmore" /><p>This is a test of the page break issue. </p>
<hr title="Page Two Title" alt="Page Two Alias"
class="system-pagebreak" />
<p>This is page two.</p><p>This is a test of the page break issue. </p>
<hr class="system-pagebreak" title="Page Three Title"
alt="Page Three Alias" />
<p>This should be page three.</p>
<hr class="system-pagebreak"
alt="Page Four Alias" title="Page Four Title"/>
<p>This is page four.</p><p>This is a test of the page break issue. </p>

3. With no patch, the page breaks appear to work correctly.

So, am I missing something? Thanks.
Posted on 7 Mar 2009, 16:29 by Mark Dexter
This patch works correctly. Can change to RTC.
Posted on 8 Mar 2009, 3:00 by Ralf-Michael Stach
Comment for clarification
with the example above (Mark Dexter, 2009-03-07 22:34:07) the pagebreak itself works correctly.
The point for the patch is the pagetitle.
With an activated Pagetitle (e.g. "Pagebreaktest") only page two will correctly show "Pagebreaktest - Page Two Title" all other pages only show "Pagebreaktest" without the subtitle.
Posted on 15 Nov 2013, 20:54 by Sebastiaan de Kooter

I have the exact same issue with jce adding:

<hr class="system-pagebreak" title="1: AVAST Software: Mobile Security &amp; Antivirus" alt="1: AVAST Software: Mobile Security &amp; Antivirus" />

I tried the patch and it sort of worked (well line 137 now)


What worked: Titles are generated for individual page
What did not work: The page title is not appended to the original article title.. It is limit to ONLY the sub-page alias.

Any fix for the last part?



Posted on 16 Jan 2014, 2:09 by gekkou lipton

i change the code but still it doesnt work for me.

can anyone please help


Commit made on 8 Mar 2009, 15:14 by Wilco Jansen
[#14525] **pagebreak doesn't work correct if using JCE