Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何覆盖Joomla系统消息-message.php模板_Joomla_Joomla2.5_Joomla3.1 - Fatal编程技术网

如何覆盖Joomla系统消息-message.php模板

如何覆盖Joomla系统消息-message.php模板,joomla,joomla2.5,joomla3.1,Joomla,Joomla2.5,Joomla3.1,默认情况下,Joomla以 libraries/joomla/document/html/renderer/message.php 对于我自己的模板,我想自定义这些消息的显示方式。但是,以传统的方式,使用模板覆盖似乎是不可能的 这里有人知道这样做的方法吗 模板覆盖仅适用于 在不攻击核心的情况下,您所能做的就是控制模板中标记周围的HTML标记以及为消息块元素定义的CSS。对于Joomla!1.7-2.5 您需要将libraries/joomla/document/html/renderer/mes

默认情况下,Joomla以

libraries/joomla/document/html/renderer/message.php

对于我自己的模板,我想自定义这些消息的显示方式。但是,以传统的方式,使用模板覆盖似乎是不可能的


这里有人知道这样做的方法吗

模板覆盖仅适用于


在不攻击核心的情况下,您所能做的就是控制模板中
标记周围的HTML标记以及为消息块元素定义的CSS。

对于Joomla!1.7-2.5

您需要将
libraries/joomla/document/html/renderer/message.php
复制到
templates/YOUR_TEMPLATE/html/message.php

然后,在_模板的index.php中,需要包含该文件(因为它不会像其他覆盖一样自动包含):

现在您可以安全地覆盖
jdocumentrendermessage::render()
函数;)

为了乔姆拉!3.x


您只需要在您的_模板中创建html/message.php文件。此文件应包含函数renderMessage()。例如,检查isis默认模板。

将覆盖包含在模板目录中的更优雅的方法是将文件包含在系统插件中:

public function onAfterInitialise() {
    $app = JFactory::getApplication();
    if ($app->isSite()) {
        $template = $app->getTemplate();
        if (!class_exists('JDocumentRendererMessage') && file_exists(JPATH_THEMES . '/' . $template . '/html/message.php')) {
            require_once JPATH_THEMES . '/' . $template . '/html/message.php';
        }
    }
    return true;
}


将此扩展用于Joomla的默认消息。

这在不破坏核心的情况下非常有效,并且完全覆盖默认消息。在J3.x:将“message.php”放在“{my_template}/html/layouts/Joomla/system”并从$displayData['msgList']提取消息(检查Beez3模板)试着解释答案而不是给出链接…因为这些链接在将来可能不可用不,不是。如果只是想覆盖模板,只需将适当的文件放在它们应该位于的位置。。。不需要编写插件来完成MVC中已经包含的工作。
public function onAfterInitialise() {
    $app = JFactory::getApplication();
    if ($app->isSite()) {
        $template = $app->getTemplate();
        if (!class_exists('JDocumentRendererMessage') && file_exists(JPATH_THEMES . '/' . $template . '/html/message.php')) {
            require_once JPATH_THEMES . '/' . $template . '/html/message.php';
        }
    }
    return true;
}