codeigniter + hmvc + smarty或使用模块中的公共库 [英] codeigniter + hmvc + smarty or using common libraries within modules

查看:134
本文介绍了codeigniter + hmvc + smarty或使用模块中的公共库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用CI,HMVC和Smarty构建网站。这是我第一次使用HMVC,我不明白如何在模块中使用通用库。

I'm building a website using CI, HMVC and Smarty. It's my first time using HMVC and I don't understand how I can use common libraries within the modules.

我喜欢在我的网站上使用Smarty,通常是一块蛋糕:我创建一个包装的s​​marty,自动加载它,并在必要的控制器中使用它。但现在我需要在模块控制器中使用smarty,我不知道如何访问它。任何想法如何我可以这样做?

I prefer using Smarty on my sites and usually it's a piece of cake: I create a wrapper for smarty, autoload it and use it in controllers where necessary. But now I need to use smarty within the module controller and I don't know how to access it. Any ideas how I can do that?

我已经研究了这个问题了几天,没有运气。

I've been researching the issue for a couple of days, with no luck.

有一些答案,我只是不能得到: like this one

There are some answers which I just don't get: like this one

编辑:CI 2.1.0,HMVC 5.4,Smarty 3.1.6(但这是不相干的)

CI 2.1.0, HMVC 5.4, Smarty 3.1.6 (but this is irrelevant)

推荐答案

以下是几种方法:

>

In application/libraries

只需将常用库放在application / libraries文件夹中,并使用 $ this-> load-> library('my_library') ;

Just put the common libraries in application/libraries folder and load using $this->load->library('my_library');

创建公共模块

选项将是创建一个新模块,让我们说 common ,其中可以有 libraries models helpers 。在这里您可以放置​​其他模块通用的文件。然后,您可以使用 $ this-> load-> library('common / my_library');

Another option would be to create a new module, lets say common, in which you can have folders libraries,models,helpers. Here you can put files which are common to other modules. You can then load them using $this->load->library('common/my_library');

我希望有所帮助。

这篇关于codeigniter + hmvc + smarty或使用模块中的公共库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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