首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Clementine框架中覆盖模块

如何在Clementine框架中覆盖模块
EN

Stack Overflow用户
提问于 2016-07-26 09:43:57
回答 1查看 26关注 0票数 0

我想改变我已经安装的Clementine模块的行为。

我知道我永远不应该更改app/share/中的代码,因为我的更改将被销毁。我怎样才能让他们坚持下去?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-07-26 10:03:01

只要覆盖你想要的函数。您可以覆盖控制器、模型、助手、视图块和配置文件。

对于controllersmodelshelpers,可以扩展定义要更改的代码的类。Clementine将自动在任何地方使用您的代码,而不是覆盖的代码。

例如,il您希望覆盖控制器Users::createAction() (在app/share/users/ctrl/usersUsersController.php中定义),创建一个新文件app/local/site/ctrl/siteUsersController.php,如下所示:

代码语言:javascript
复制
<?php
class siteUsersController extends siteUsersController_Parent
{
    public function indexAction($request, $params = null)
    {
        //do your specific stuff here
        //then return parent:: function 
        return parent::indexAction($request, $params);
    }
}

如果要重写视图,例如在app/share/users/view/users/index.php中定义的块,请创建如下所示的新文件app/local/site/view/users/index.php

代码语言:javascript
复制
<?php
//display specific stuff here
//then display parent block
$this->getParentBlock($data, $request);

如果要重写某些configuration,(例如,在文件app/share/users/etc/config.ini[module_users]部分中定义的send_account_confirmation选项),请编辑app/local/site/etc/config.ini文件,添加[module_users]部分并重写该选项:

代码语言:javascript
复制
[module_users]
send_account_confirmation="1"
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38586397

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档