如何在所有模板中应用自定义的方法

0 views
Skip to first unread message

Xinhao Zheng

unread,
Jun 4, 2007, 9:31:38 PM6/4/07
to Seagull中文讨论区
最近有人在SGL英文Google上提出了这个问题,而且认为除了修改SGL_Output类没有其它的办法。但是事实上,SGL从0.6.2版本开始
已经考虑了这个问题。

$outputClass = SGL_FrontController::getOutputClass($input-
>getConfig());
$output = &new $outputClass();

对比一下0.6.1的代码:

$output = &new SGL_Output();

也就是说,在0.6.1中你可能真的是除了修改SGL_Output类是没有别的办法,但是在0.6.2中,SGL的开发都已经为我们想到了这个问题。
你可以使用自己定义的output类,当然最好还是通过继承SGL_Output类然后添加自定义方法。如:

class Output extends SGL_Output
{
function foo()
{
//做你想做的操作了
}
}
当然你还需要在你的全局配置文件中做相关的设置:
$conf['site']['globalJavascriptOnUnload'] = '';
$conf['site']['customOutputClassName'] = '';//在这里真你自定义的输出类名

这也是demian所推荐的方法,只是还没有在SGL文档中说明,SGL的文档也真的应该更新了。好多功能都还没有在手册中体现,我们只能去猜测。

Reply all
Reply to author
Forward
0 new messages