覆盖Joomla核心组件文件 [英] Overriding Joomla core component file

查看:98
本文介绍了覆盖Joomla核心组件文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用此页面

它说我必须在基本目录中创建一个名为"code"的文件夹,并创建相同的目录结构.我试过了,但是没有用.有人可以确认其是否正常工作.

It says I have to create a folder named 'code' in base directory and create the same directory structure. I tried it , but its not working. Can someone confirm whether its working.

我应该在哪里创建代码文件夹?是在joomla安装的根目录上吗?

Where should I create code folder? Is it on root of joomla installations?

PS-应用于核心文件时,编辑工作正常

PS- The edit is working correctly when applied on core file

推荐答案

如果先加载具有相同名称的类,则可以覆盖(几乎)Joomla中的任何类.为此,您需要创建一个系统插件.

You can override (nearly) any class in Joomla, if your class with the same name is loaded first. To ensure that, you need to create a system plugin.

以下是root/components/com_content/views/article/view.html.php的示例:

Here is an example for root/components/com_content/views/article/view.html.php:

class plgSystemOverride extends JPlugin
{
    public function onAfterRoute()
    {
        JLoader::register('ContentViewArticle', 'path/to/override.php', true);
    } 
}

注意:如果您不太谨慎的话,重写核心类可能会导致其他扩展的问题.不过,对于视图来说,与其他扩展名之间的任何干扰都不太可能.

CAVEAT: Overriding a core class can lead to problems with other extensions, if you're not very careful. For views, though, any interferrence with other extensions is less likely.

这篇关于覆盖Joomla核心组件文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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