简体   繁体   English

Joomla内容插件

[英]Joomla content plugin

How do I get this plugin triggered in the Joomla core "user manager" when a list of user is displayed? 显示用户列表时,如何在Joomla核心“用户管理器”中触发此插件?

I have already enabled in the plugins table but it is still not working. 我已经在插件表中启用了它,但是它仍然无法正常工作。 What I have not done? 我还没做什么?

// no direct access
defined('_JEXEC') or die('Restricted access');
// register the handler
$mainframe->registerEvent('onPrepareContent', 'plgContentUserswi');
/**
 * 
 * 
 * @param object Content item
 * @param JParameter Content parameters
 * @param int Page number
 */
function plgContentUserswi(&$row, &$params, $page)
{
    var_dump($row);
}

I might be wrong or misuderstood this book here. 我可能在这里错了或误读了这本书。 I am not saying the book is wrong but maybe I have misunderstand the interpretation or some earlier explaination that i have missed. 我并不是说这本书是错的,但也许我误解了我所错过的解释或一些较早的解释。 on page 223 of this book it says the following: 在本书第223页上,它说:

Content 内容
The content plugins allow us to modify content items before we display them. 内容插件使我们可以在显示内容项之前对其进行修改。 The most commonly used content event is onPrepareContent. 最常用的内容事件是onPrepareContent。 This event, always the frst of all the content events to be triggered, is used to modify the text content. 此事件始终是要触发的所有内容事件的第一个,用于修改文本内容。 Let's imagine we want to create a content plugin which will replace all occurrences of :) with a small smiley face icon. 假设我们要创建一个内容插件,该插件将用一个小的笑脸图标替换所有出现的:)。 This is how we could implement this: 这是我们可以实现的方式:

// no direct access
defined('_JEXEC') or die('Restricted access');
// register the handler
$mainframe->registerEvent('onPrepareContent', 
                          'plgContentSmiley');
/**
 * Replaces :) with a smiley icon.
 * 
 * @param object Content item
 * @param JParameter Content parameters
 * @param int Page number
 */
function plgContentSmiley(&$row, &$params, $page)
{
  $pattern = '/\:\)/';
  $icon = '<img src="plugins/content/smiley.gif" />';
  $row->text = preg_replace($pattern, $icon, $row->text);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM