?
avatar avjoomla
avjoomla
11 Jul 2015

Up to Joomla! 3.4.0 it was possible to change the document title in the code of a content plugin.

In Joomla! 3.4.0 content plugins were triggered with the following code
(line 163) $results = $dispatcher->trigger('onContentAfterTitle', array('com_content.article', &$item, &$this->params, $offset));
Since Joomla! 3.4.1 the code was changeed to
(line 1643) $results = $dispatcher->trigger('onContentAfterTitle', array('com_content.article', &$item, &$item->params, $offset));
So instead of &$this->params now &$item->params is used.

As $this->params is not set to the $item->params afterwards, changes made to the params in a content plugin are only available in the display function of the view class but not in the _prepareDocument function which actually does use the params.

The problem could be fixed by adding the following line to the display function after line 180

  • 181 $this->params = $item->params; Alternatively the parameter passed to the plugin could be reverted to &$this->params whenever the content plugins are triggered. (line 163, 166, 169) As far as I have seen, teh problem does orccur in all views of the com_content.

Regards,
Aicha

avatar avjoomla avjoomla - open - 11 Jul 2015
avatar brianteeman
brianteeman - comment - 11 Jul 2015

Do you have a plugin you can share that will help to make testing easier

avatar Bakual
Bakual - comment - 11 Jul 2015

Did you try to use a different plugin event? Thing is that onContentAfterTitleisn't really meant for such tasks. It is meant to return a string which is displayed after the title.

avatar zero-24 zero-24 - change - 12 Jul 2015
Labels Added: ?
avatar zero-24 zero-24 - change - 12 Jul 2015
Category Plugins
avatar avjoomla
avjoomla - comment - 13 Jul 2015

I used the onContentPrepare event which is not working, too.

If you like, I could send you my plugin to test with.

avatar Bakual
Bakual - comment - 13 Jul 2015

All onContent events aren't meant to change the document itself. They are meant to deal with the content passed in.
You could probably set the document title in a later (system) event. If you need the $item you could do it using two events. One of the onContent... events to fetch the needed data and a later one to alter the document title.

avatar avjoomla
avjoomla - comment - 13 Jul 2015

So this is an intended change in the interface? Because up to Joomla! 3.4.0 it worked with the onContent... events and that made a lot of sense to me. Which later event would you advice to use?

avatar Bakual
Bakual - comment - 13 Jul 2015

I'd say it was an intended change, yes. I would have to search the change though.

I would probably use https://docs.joomla.org/Plugin/Events/System#onBeforeRender.

avatar avjoomla
avjoomla - comment - 13 Jul 2015

Thanks, I'll check on that event but I would really appreciate if somebody would check if this really is an intended change or not because, as I wrote, it made perfectly sense to me to be able to change the document parameteres at that point, too.

avatar Bakual
Bakual - comment - 13 Jul 2015

Change was #5016

avatar avjoomla
avjoomla - comment - 13 Jul 2015

Thanks for the information!
And yes, the onBeforeRender() event works perfectly for my purpose.

avatar avjoomla avjoomla - change - 13 Jul 2015
Status New Closed
Closed_Date 0000-00-00 00:00:00 2015-07-13 10:20:09
Closed_By avjoomla
avatar avjoomla avjoomla - close - 13 Jul 2015

Add a Comment

Login with GitHub to post a comment