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

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