关于模板中踊跃获取数据,大家有什么好的方法

WBOY
Release: 2016-06-13 13:19:38
Original
903 people have browsed it

关于模板中主动获取数据,大家有什么好的方法
为了防止程序中提供数据,而模板中没有使用到的情况发生,同时也为了更好的让制作模板的人自由发挥,做到根据模板需要获取数据,以往的方式,我是编写了很多标签函数,供模板调用,直接在模板中插入标签函数即可获取数据,最近把程序改成框架模式开发了,将原来的标签函数写在Tag类库中,调用的时候用Tag::func()方式当然也是没有问题的,但是这样的话,增加的不同的模块,需要显示的部分,都要添加到这个类库中,不方便扩展,所以想把显示部分也直接写在对应的模块的模型类中,而在Tag类库中增加一个方法,实现根据模型名称与方法名称调用不同模型的方法,这里有个问题,类里面方法的调用有两种:1是作用域方式,2是对象方式,有没有办法做到,自动判断能否使用作用域方式调用,如果不能的话,再用对象方式调用?

------解决方案--------------------
做到根据模板需要获取数据
我就知道这个需求是普遍的http://topic.csdn.net/u/20120522/14/51e081ae-baa8-47ea-9257-268c4ca3be60.html

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!