onContentBeforeDisplay Category $limitstart returns "0"

For Joomla! 3.x Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general

Moderator: ooffick

Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
Post Reply
User avatar
Joomla! Apprentice
Joomla! Apprentice
Posts: 28
Joined: Wed Jul 16, 2014 9:56 pm

onContentBeforeDisplay Category $limitstart returns "0"

Post by dmorell » Thu Jun 21, 2018 5:20 pm

I am working on a plugin. It needs to be able to return a value that is dependant on the com_content category view pagination.

I am relatively new to Joomla plugin development. I was under the impression that $limitstart should return the starting number of the article displayed. Thus if there are 10 articles per page, and the user viewing page 2, it should return a value of 10.

I am using the following code in my plugin to test the value of $limitstart. It returns a value of 0 on all pages.

Code: Select all

public function onContentBeforeDisplay($context, &$item, &$params, $limitstart) {
	$app     = JFactory::getApplication();
	$option = $app->input->get('option');
	$view   = $app->input->get('view');
	if ($context == "com_content.category" && ($option == "com_content" && $view == "category")) {
	return $limitstart;
I figure there are two possibilities:
  1. I don't understand the purpose of $limitstart.
  2. My code is wrong.
Some help would be very much appreciated!

User avatar
Joomla! Ace
Joomla! Ace
Posts: 1631
Joined: Thu Sep 13, 2007 11:39 am
Location: UK

Re: onContentBeforeDisplay Category $limitstart returns "0"

Post by fcoulter » Thu Jun 21, 2018 7:54 pm

You could use

Code: Select all

		$limitstart = $app->input->get('limitstart', 0, 'uint');

to get the value.

Looking at the template code for com_content, the $page value passed to onContentBeforeDisplay is always 0, so you cannot use that to get the value. I don't know why this is though, it seems like it should would the way that you describe, but doesn't.

In the blog.php template for example you have

Code: Select all

$results = $dispatcher->trigger('onContentBeforeDisplay', array($this->category->extension . '.categories', &$this->category, &$this->params, 0));
So the parameter is never going to have a non-zero value.

I don't think that there is anything wrong with your understanding of limitstart, just in the way that you are trying to get it.
http://www.spiralscripts.co.uk for Joomla! extensions
http://www.fionacoulter.com/blog my personal website
Security Forum moderator :: VEL team member
"Wearing my tin foil hat with pride"

Post Reply

Return to “Joomla! 3.x Coding”