[英]Include contents from a php script into typoscript
我想使用一个lib对象将一个php脚本的输出包含到typoscript中...我不幸失败了:)
我这样声明lib对象:
TS:
includeLibs.bannerLib = fileadmin/banner/banner.php
lib.banner = USER
lib.banner{
userFunc = user_banner->user_showBanner
}
然后,我需要使用变量(?)将其包括在TS的其余部分中:
{f:cObject(typoscriptObjectPath:lib.banner)}
这很可能在失败的地方。 我没有使用流体,但是我猜f:cObject是指流体模板吗?
这是我正在使用的(非常简单的)PHP脚本:
class user_banner{
public $cObj;
/**
* Scans the files in the images folder
* for images and returns it, if present
*/
public function user_showBanner($content, $conf){
$images = scandir('images');
return implode(',', $images);
}
}
我究竟做错了什么??? 我正在使用Typo3 4.6.x
[编辑]
该页面是由一些T3裂缝制成的,并且整个内容都包裹在一个lib对象中,然后使用某种lib呈现(我猜)。 这是它的样子(部分):
lib{
markupBodyColumns {
1 >
2 {
value (
<div id="col2" class="col">
//here I try to insert my banner
<span class="bannerClass">{$lib.banner}</span>
<div class="pageTitle">
{renderLib:markupBodyPageTitle}
</div>
<div class="contentWraper">
<div class="content">
{renderLib:markupBody}
</div>
{renderLib:markupFooter}
</div>
</div>
)
}
}
[编辑2]
好吧,这真让我发疯...确实如此...
第一次更正:我使用的是Typo3 4.6.x,而不是前面提到的4.7.x
我试图将userFunc包含在打字稿中,但它拒绝吐出任何东西。 上面的PHP函数(类)保持不变。 类中的函数根本没有被调用。
在打字稿中,我尝试过:
第一次尝试:
includeLibs.user_banner = fileadmin/banner/user_banner.php
lib.myBanner = USER_INT
lib.myBanner{
userFunc = user_banner->user_showBanner
}
page.100000 < lib.myBanner
无任何输出
第二次尝试:
page = PAGE
page.200000 = USER_INT
page.200000.userFunc = user_banner->user_showBanner
再次-不输出...
我到底在做什么错???
如果您未在网站中使用Fluid,则不会产生任何输出,因为
{f:cObject(typoscriptObjectPath:'lib.banner')}
是Fluid ViewHelper的内联符号,只能在Fluid模板中使用。
使用TypoScript和userFunc,您将在lib.banner中获得showBanner的返回值。 您只需要将其显示在网站上的某个位置即可。
如果您的网站中有PAGE对象,则可以如下将其添加到页面中:
page.20141031 < lib.banner
(其中20141031是唯一编号,尚未用于PAGE对象的另一部分。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.