Joomla 3
I was trying to modify Joomla's pagination output. Following this documentation, I create mytemplate/html/pagination.php file and start modifying it. According to the document, I can write 4 functions in the new pagination file, I actually just want to rewrite _list_render() and _item_active(). However, in libraries/cms/pagination/pagination.php beginning from line 327
$chromePath = JPATH_THEMES . '/' . $this->app->getTemplate() . '/html/pagination.php'; if (file_exists($chromePath)) { include_once $chromePath; if (function_exists('pagination_item_active') && function_exists('pagination_item_inactive')) { $itemOverride = true; } if (function_exists('pagination_list_render')) { $listOverride = true; } } This means I can only get CMS to use my function if only both pagination_item_active() and pagination_item_inactive() exist. But I don't have my own pagination_item_active(), so I copy the content of _item_active() in the CMS's pagination.php to my override file so it looks like this in my pagination.php
...... function pagination_item_active(JPaginationObject $item){ $title = ''; $class = ''; if (!is_numeric($item->text)) { JHtml::_('bootstrap.tooltip'); $title = ' title="' . $item->text . '"'; $class = 'hasTooltip '; } if ($this->app->isAdmin()) { return '<a' . $title . ' href="#" onclick="document.adminForm.' . $this->prefix . 'limitstart.value=' . ($item->base > 0 ? $item->base : '0') . '; Joomla.submitform();return false;">' . $item->text . '</a>'; } else { return '<a' . $title . ' href="' . $item->link . '" class="' . $class . 'pagenav">' . $item->text . '</a>'; } }
The problem is, when I run the PHP, I get this error message:
Using $this when not in object context in
/home/w/public_html/templates/rt_photon/html/pagination.php on line 56
What I don't understand is, my pagination.php is supposed to be included into the CMS's one, where there is an "object context", why then is it giving this error message? And how do I overcome this dillema?