Bug: SP Author Archive cuts intro text in the middle of HTML tags, which breaks the article grid and pagination - Forum | JoomShaper
Awaiting an answer Extensions Joomla 6 v2.0.2

Bug: SP Author Archive cuts intro text in the middle of HTML tags, which breaks the article grid and pagination

Asked by HalTurner 1 hour ago

Environment

  • SP Author Archive 2.0.2
  • Gazette template 2.0.5 (Helix Ultimate), which ships its own override of the Author Archive articles layout
  • Joomla 6.2.0, PHP 8.3
  • News site with several thousand articles; many intro texts use bold, coloured text or links

The problem

On an author's articles page, each card shows a shortened intro. The layout shortens the intro by cutting the raw HTML at a fixed number of characters (150 by default, the "intro text limit" setting) and adding three dots. It does not remove or close the HTML formatting first.

The code is in two places:

  • the component layout: components / com_spauthorarchive / layouts / articles / articles.php, around line 54
  • Gazette's override of it: templates / shaper_gazette / html / layouts / com_spauthorarchive / articles / articles.php, lines 88-89 (this is the one that renders on Gazette sites)

When the cut falls inside bold or coloured text, the opening bold tag is printed but its closing tag is not. The browser then treats everything after that point as part of the bold text:

  • all following article cards drop out of the card grid. They stack one per line, narrower each time, so the page becomes very long
  • the pagination ends up inside the bold text as well. The PREV and NEXT buttons overlap on the left of the bar, away from the page numbers
  • which pages break depends on which intros happen to be cut inside formatting, so some page numbers look fine and others don't

Checked on a live author page (page 4, 9 articles):

  • One intro started with bold red text and was cut inside it.
  • In the browser's element inspector, cards 8 and 9 and the pagination block sat inside that unclosed bold element, not inside the card row.
  • As a test, I replaced only the 9 intros with their plain text in the browser. All 9 cards went back into the 4-column grid, and the pagination showed PREV, the page numbers and NEXT normally on one bar.

Two smaller issues come from the same approach:

  • The cut counts bytes, not characters, so it can also split an accented or other multi-byte character at the end of the teaser.
  • The authors list layout (components / com_spauthorarchive / layouts / authors / authors.php, line 54) shortens the author description the same way, at 218 characters, with the same risk.

Suggested fix

Remove the HTML from the intro before shortening it, and shorten it with Joomla's own string truncate helper from the HTMLHelper class, with HTML not allowed. That helper cuts at a word boundary, is UTF-8 safe and adds the dots only when it actually cuts.

If you prefer to keep the formatting, Joomla's "truncate complex" helper closes any open tags instead.

Please apply the same change to:

  • the component's articles layout
  • Gazette's override of it, and the matching overrides in your other templates that bundle SP Author Archive
  • the author description in the authors layout

Intros without formatting look the same as today, apart from the cleaner word-boundary cut.

Impact

  • Every site whose article intros contain formatting, which is most sites using the editor's bold/colour/link buttons.
  • Visible to every visitor of the author pages: broken grid, very long pages, unusable pagination.
  • A one-line change per layout, with no database or settings change.

We are applying this change locally as a temporary patch and will remove it once a fixed version is out. Happy to test a build.

Log in to reply.