Reputation: 357
I have created and successfully installed a plugin in Joomla 2.5 with the following code
<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
class plgCustomFunctions extends JPlugin
{
public function onContentPrepare($context, &$article, &$params, $page = 0)
{
$article->title = "Something!";
return true;
}
}?>
My understanding is that this should overwrite the title of every article. That isn't happening. What am I missing?
Upvotes: 1
Views: 993
Reputation: 7576
I think the problem is in the class name, it should be
class plgContentCustomFunctions extends JPlugin
Otherwise Joomla autoloader won't be able to find it
Offtopic: anyone interested in adding tag synonyms for Joomla, please give your opinion
Upvotes: 6
Reputation: 42622
So first of all, make sure that your plugin is properly installed and it's activated.
Your problem is that you are trying to set a property that does not really exist:
$article->title = "Something!";
If you do a var_dump($article);
you will see that the only property passed is 'text'.
So with this
$article->text = "Something!";
This is obviously a limitation of the onContentPrepare method.
Maybe you can find an event that triggers when saving the article.
Upvotes: 0