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

查看:16
本文介绍了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天全站免登陆