我正在尝试将一个简单的插件部署到Joomla 2.5安装中。插件中的代码在类声明之外运行,并将两个脚本标记添加到头部。但是,内部的代码什么都不做。我无法更改$ article->标题或$ article->文字。我从不同的文章中逐字复制和粘贴,但一切似乎只谈了1.5。我发现的1.7内容只提到将onParepareContent更改为onContentPrepare。似乎都没有做任何事情。我将不胜感激任何帮助!
<?php
// No direct access.
defined( '_JEXEC' ) or die( 'Restricted access' );
class plgContentPicasaGallery extends JPlugin
{
/**
*
* @param string The context of the content being passed to the plugin.
* @param mixed An object with a "text" property.
* @param array Additional parameters.
* @param int Optional page number. Unused. Defaults to zero.
* @return boolean True on success.
*/
public function onContentBeforeDisplay($context, &$article, &$params, $page = 0)
{
if (is_object($article)) {
$article->text = "omfg, wtf?";
return true;
} else {
$article = "omfg, I'm not an object, wtf?";
return true;
}
}
}
答案 0 :(得分:2)
Joomla文档&amp;教程有点陈旧,新框架改变了一些东西。
要查找正确的签名,只需查看/plugins/content/...
个文件。
以下是正确的功能签名&amp; onContentPrepare
的phpdoc。
/**
* @param string The context of the content being passed to the plugin.
* @param object The article object. Note $article->text is also available
* @param object The article params
* @param int The 'page' number
*/
public function onContentPrepare($context, &$article, &$params, $page = 0)
{
...
}
答案 1 :(得分:1)
我对Joomla的无礼优先于我的理智。我正在编辑服务器上的插件文件,我希望能够更新插件。谢谢你的帮助!
答案 2 :(得分:0)
你可以使用这种方法
jimport('joomla.form.helper');
$urla= JRequest::getVar('id');
$urlview= JRequest::getVar('view');
if ($urlview=='article')
{}
if ($urla==10<- number id article )
{}
我知道框架joomla很好,但它用于理解方法