Plugins onContentBeforeSave和onContentAfterSave未触发
我知道这里有很多问题与同一个问题,但我已经通过了所有的解决方案,我发现,并没有能够解决我的问题 从前端和后端保存文章时,不会触发onContentBeforeSave和onContentAfterSave事件。同一插件中的OnContentBeforRedisplay事件工作正常 这是我的密码,你有什么想法吗?多谢各位Plugins onContentBeforeSave和onContentAfterSave未触发,plugins,joomla,joomla3.0,Plugins,Joomla,Joomla3.0,我知道这里有很多问题与同一个问题,但我已经通过了所有的解决方案,我发现,并没有能够解决我的问题 从前端和后端保存文章时,不会触发onContentBeforeSave和onContentAfterSave事件。同一插件中的OnContentBeforRedisplay事件工作正常 这是我的密码,你有什么想法吗?多谢各位 <?php // no direct access defined( '_JEXEC' ) or die( 'Restricted access' ); jimpo
<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport('joomla.plugin.plugin');
class plgContentBillrepeat extends JPlugin {
/**
* Load the language file on instantiation. Note this is only available in Joomla 3.1 and higher.
* If you want to support 3.0 series you must override the constructor
*
* @var boolean
* @since 3.1
*/
protected $autoloadLanguage = true;
/**
* Plugin method with the same name as the event will be called automatically.
*/
function onContentBeforeSave($context, &$article, $isNew) {
JError::raiseNotice( 100, 'onContentBeforeSave plugin fired!' );
return true;
}
function onContentAfterSave($context, &$article, $isNew) {
JError::raiseNotice( 100, 'onContentAfterSave plugin fired!' );
}
function onContentBeforeDisplay($context, &$article, &$params, $limit=0) {
JError::raiseNotice( 100, 'onContentBeforeDisplay plugin fired!' );
return "";
}
}
?>
通过按值传递文章而不是通过引用来解决问题 这似乎有效:
function onContentBeforeSave($context, $article, $isNew) {
JError::raiseNotice( 100, 'onContentBeforeSave plugin fired!' );
return true;
}
function onContentAfterSave($context, $article, $isNew) {
JError::raiseNotice( 100, 'onContentAfterSave plugin fired!' );
return true;
}
虽然我不太清楚为什么,因为所有文档都清楚地指出文章应该通过引用传递,甚至我在这里看到的问题都表明,通过值传递导致事件不会被触发 通过按值传递文章而不是通过引用来解决问题 这似乎有效:
function onContentBeforeSave($context, $article, $isNew) {
JError::raiseNotice( 100, 'onContentBeforeSave plugin fired!' );
return true;
}
function onContentAfterSave($context, $article, $isNew) {
JError::raiseNotice( 100, 'onContentAfterSave plugin fired!' );
return true;
}
虽然我不太清楚为什么,因为所有文档都清楚地指出文章应该通过引用传递,甚至我在这里看到的问题都表明,通过值传递导致事件不会被触发 根据
插件事件
onContentBeforeSave事件现在按值而不是按值接收$article
参考示例定义:公共函数
onContentBeforeSave$context、$article$是新的
onContentAfterSave事件现在按值而不是按值接收$article
参考示例定义:公共函数
onContentAfterSave$context、$article、$isNew
据
插件事件
onContentBeforeSave事件现在按值而不是按值接收$article
参考示例定义:公共函数
onContentBeforeSave$context、$article$是新的
onContentAfterSave事件现在按值而不是按值接收$article
参考示例定义:公共函数
onContentAfterSave$context、$article、$isNew
我假设这是一个内容插件,你能添加你正在使用的Joomla版本以供将来参考吗?我假设这是一个内容插件,你能添加你正在使用的Joomla版本以供将来参考吗?