索引帖:
http://www.phpwind.net/read/2935788
案例: res资源引用及系统其他资源引用
找了半天终于找到个案例
插件目录下有个res目录,里面是放图片,css,js等资源的,我们如何调用呢?
笨方法是src\extensions\chat\res\这样调,但是这样不符合规范,因为src目录是可以换的,不一定在论坛的根目录下。
插件装完后,res目录会被移动到
themes/extres目录下,并且以插件名开头
我们在程序里面调用的话,只需这样写就可以了。
[code brush:text;toolbar:false;]{@G:url.extres}/chat/images/webim_icon.png[/code]如图
引用css的话这样写
[code brush:text;toolbar:false;]<link href="{@G:url.extres}/weibojuhe/weibo_forum.css" rel="stylesheet" />[/code]引用js的话这样写
[code brush:text;toolbar:false;]Wind.js('{@G:url.extres}/weibojuhe/weibo_emotion.js');//表情[/code]
案例:在插件中引用系统自带模板的方法
[code brush:text;toolbar:false;]$this->setTemplatePath('TPL:common');
$this->setTemplateExt('htm');
$this->setTemplate('my_index');[/code]其中
setTemplatePath函数,是定义了调用模板的路径,会自动识别风格的。