【发布时间】:2011-08-30 20:42:32
【问题描述】:
在前端访问 Joomla 1.6 和 1.7 中的 com_users 组件时,应用程序会自动从“用户”组导入所有插件。显然,如果不想创建一个组件来简单地将一些变量传递给一个插件,这是非常有用的。
好的。让我们让它更简单:
- 用户获得激活链接:http://example.com/index.php?option=com_users&task=edit&emailactivation=1&u=63&d077b8106=1 并点击它。
- 当然,该组件将省略 emailactivation 和其他参数,仅显示“编辑个人资料表单”(或访客登录表单)。
- 然后 JApplication 从 'user' 组导入所有插件,这会触发 __constructors
基本上,使用插件的 __constructor 可以像下面这样设置简单的操作:
class plgUserAccountactivation extends JPlugin
{
public function __construct(& $subject, $config)
{
parent::__construct($subject, $config);
if(isset($_GET['emailactivation'])) {
// check token
// activate account, email or whatever
// redirect with message
}
}
}
哇!它有效,不需要创建一个完整的控制器来处理一个简单的任务。
但是等一下……
- 在链接中将 index.php?option=com_users 更改为 index.php?option=com_user
- 让我们试试 Joomla 1.5...
嘿,嘿,什么都没有发生 com_user 根本没有导入任何东西,也没有调用 __constructor。
我在 Joomla 1.5 中对此感到非常困扰,我不想编写整个组件。
如果有人有什么好主意,请告诉我。
编辑: 我通过以下形式发送链接解决了我的问题:
http:/example.com/index.php?option=com_user&task=logout&emailactivation=1&u=63&d077b8106=1
通过这种方式包含用户插件并执行 __constructors。但这太无聊了,因为 task=logout 并不真正鼓励点击链接。
【问题讨论】:
标签: php model-view-controller joomla joomla1.5 joomla-extensions