Skip to main content
1 of 4
Nadal
  • 188
  • 9

Joomla pagebreak causing 404 error in custom pagebreak coding. Seeking a solution

I wrote a function in an article override to search a folder for images and create a pagebreak behavior in articles per image. All works fine except for a 404 error being returned for each pagination link.

I determined that the error is caused by Joomla's pagebreak content plugin pagebreak.php where the condition is:

if (StringHelper::strpos($row->text, 'class="system-pagebreak') === false)
    {
        if ($page > 0)
        {
            throw new Exception(JText::_('JERROR_PAGE_NOT_FOUND'), 404);
        }

        return true;
    }

If I comment out the line throw new Exception(JText::_('JERROR_PAGE_NOT_FOUND'), 404); or disable the plugin the process works perfectly. However, being that the file is subject to overwriting on updates, that is not an ideal option.

My code is:

$imagesDir = JPATH_ROOT.'/images/photogallery/'.$folder.'/';
$images = str_replace(JPATH_ROOT, Juri::root(true), glob($imagesDir . '*.{jpg,jpeg,png,gif}', GLOB_BRACE));

foreach($images as $image) {
    $page_break[] = '<img src="'.$image.'" />';
}

$pagenum = 0;
if( $app->input->get('start') !='' )
    $pagenum = $app->input->getInt('start');

$pages = count($page_break);
    
if( $pages > 0 )
{
    $pagelinks = new JPagination($pages, $pagenum, 1);
    $pagebreak .= $page_break[$pagenum];
    
    $pagebreak .= '
    <div class="paging">
        <div class="pagecount">'.$pagelinks->getPagesCounter().'</div>
        <div class="pager">'.$pagelinks->getPagesLinks().'</div>
    </div>
    ';
}

How can I resolve this error occurrence?

Nadal
  • 188
  • 9