joomla 1.7:覆盖模块helper.php

发布于 2024-12-24 00:08:48 字数 210 浏览 1 评论 0原文

我想准确地覆盖模块的 helper.php 文件

\administrator\modules\mod_quickicon\helper.php

我想要的是更新此文件中的 getButtons 函数,

我必须覆盖此特定文件的选项是什么?可以使用插件吗?

谢谢

I want to override a helper.php file of a module, exactly

\administrator\modules\mod_quickicon\helper.php

what I want is to update the getButtons function in this file

what are the options I have to override this particular file ? its possible using a plugin ?

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

千仐 2024-12-31 00:08:48

您实际上只能对 tmpl 文件夹中名为 default.php 的文件进行模板覆盖。如果您想覆盖 helper.php,您实际上是在重写模块本身。这不一定是坏事,只需将现有 helper.php 文件的内容复制到另一个文件中进行备份,然后破解即可。这样做的缺点是,如果有人更新了模块,而您安装了该更新,则必须重新进行黑客攻击。再说一次,解决这个问题并不难。只需备份备份备份即可。

还有一些想法:
您还可以执行以下操作:
1) 将模块复制到另一个文件夹,同样以 mod_ 开头,但名称不同。
2) 修改 xml 文件、帮助程序文件、组件文件(以及任何其他必要的文件)以适应新名称。也可以对 helper.php 做任何你想做的事情。
3) 转到扩展管理器并发现安装这个新模块
4) 转到模块管理器并创建新模块的新实例(使用与旧模块相同的位置)。
5) 取消发布您要替换的模块

这样做可以避免更新丢失。

You can really only do a template override on the file in the tmpl folder called default.php. If you want to override helper.php, you're essentially rewriting the module itself. This isn't necessarily a bad thing, just copy the contents of the existing helper.php file into another file for backup, and hack away. The downside of doing this is that if someone updates the module, and you install that update, you'll have to redo your hack. Again, it's not that hard to work around. Just backup backup backup.

Some more thoughts:
You could also do the following:
1) Copy the module to a different folder, beginning with mod_ as well, but with a different name.
2) Modify the xml file, helper file, component file (and any others that are necessary) to account for the new name. Also do whatever you want to helper.php.
3) Go to extension manager and do a discover install of this new module
4) Go to module manager and make a new instance of the new module (using the same position as the old one).
5) Unpublish the module you're replacing

Doing this will keep you safe from update loss.

难忘№最初的完美 2024-12-31 00:08:48

这是我用 Joomla 所做的! 3.3.1 但可以用 Joomla! 来完成! 1.7 也是:

  • 复制 default.php 来自

    /administrator/modules/mod_quickicon/tmpl/
    

    /administrator/templates/YOUR_ADMIN_TEMPLATE_NAME/html/mod_quickicon/
    
  • 打开复制的文件并替换下面的行

    $html = JHtml::_('links.linksgroups', ModQuickIconHelper::groupButtons($buttons));
    

    用这些行:

    $myLinks = 数组(
        'YOUR_QUICKICON_GROUP_NAME' =>大批(
            大批(
                '链接' => JRoute::_('index.php?option=com_YOURCOMPONENT'),
                '图像' => '堆',
                '图标' => '标题/icon-48-article-add.png',
                '文本' => JText::_('YOUR_QUICKICON_ITEM_NAME'),
                '访问' =>数组('core.manage','com_YOURCOMPONENT'),
                '组' => “YOUR_QUICKICON_GROUP_NAME”
            )
        )
    );
    
    $array = ModQuickIconHelper::groupButtons($buttons);
    $array = array_merge($myLinks, $array);
    
    $html = JHtml::_('links.linksgroups', $array);
    

就是这样。您可以编辑或创建 /administrator/language/overrides/en-GB.override.ini 并添加以下行:

YOUR_QUICKICON_GROUP_NAME="The Group"
YOUR_QUICKICON_ITEM_NAME="The Item"

享受吧!

Here is what I've done with Joomla! 3.3.1 but it might be done with Joomla! 1.7, too:

  • Copy default.php from

    /administrator/modules/mod_quickicon/tmpl/
    

    to

    /administrator/templates/YOUR_ADMIN_TEMPLATE_NAME/html/mod_quickicon/
    
  • Open the copied file and replace the line below

    $html = JHtml::_('links.linksgroups', ModQuickIconHelper::groupButtons($buttons));
    

    with these lines:

    $myLinks = array(
        'YOUR_QUICKICON_GROUP_NAME' => array(
            array(
                'link' => JRoute::_('index.php?option=com_YOURCOMPONENT'),
                'image' => 'stack',
                'icon' => 'header/icon-48-article-add.png',
                'text' => JText::_('YOUR_QUICKICON_ITEM_NAME'),
                'access' => array('core.manage', 'com_YOURCOMPONENT'),
                'group' => 'YOUR_QUICKICON_GROUP_NAME'
            )
        )
    );
    
    $array = ModQuickIconHelper::groupButtons($buttons);
    $array = array_merge($myLinks, $array);
    
    $html = JHtml::_('links.linksgroups', $array);
    

That's it. You can edit or create /administrator/language/overrides/en-GB.override.ini and add these lines:

YOUR_QUICKICON_GROUP_NAME="The Group"
YOUR_QUICKICON_ITEM_NAME="The Item"

Enjoy!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文