Joomla:是否存在模块渲染插件事件? [英] Joomla: Is there a module render plugin event?

查看:121
本文介绍了Joomla:是否存在模块渲染插件事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某些缓存问题,如果存在某些URL参数,则需要显式绕过特定模块的缓存.我到达的解决方法是按照以下方式破解libraries/joomla/document/html/renderer/module.php中的render()函数:

Due to some caching issues, I need to explicitly bypass the cache, for a specific module, if certain URL parameters are present. The workaround I've arrived at is to hack the render() function in libraries/joomla/document/html/renderer/module.php, along the lines of:

function render( $module, $params = array(), $content = null )
{
    // Existing code:
    $mod_params = new JParameter( $module->params );

    // My hack:
    if ($module->module == 'mod_foo')
    {
        if (certain URL parameters are present)
        {
            $mod_params->set('cache', 0);
        }
    }
    ...
}

当然,破解核心的joomla代码是一个可怕的主意,我想尽可能避免这种主意.那么,是否可以插入一个合适的钩子以实现相同的效果?我认为我无法在模块级别上做任何事情,因为如果渲染器已经决定从缓存中获取它,甚至将不会对其进行检查.

Of course, hacking the core joomla code is a terrible idea, one which I'd like to avoid if at all possible. So, is there an appropriate hook I can plugin to in order to achieve the same? I don't think I can do anything at the module level, since it won't even be inspected if the renderer has already decided to fetch it from cache.

推荐答案

要回答第一个问题,没有模块渲染事件,请参见插件文档以及Joomla中的事件列表!

To answer the first question no there isn't a module render event, here's the plugin doc's and the list of events in Joomla!

关闭模块的缓存.

请参阅《 Joomla的艺术》 上的这篇文章,您可以查看其他文章在:

See this article on The Art Of Joomla, additional articles you could look at:

  1. 使用缓存来加速代码

JCache API

这篇关于Joomla:是否存在模块渲染插件事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆