简体   繁体   English

将php脚本中的内容包含到排字中

[英]Include contents from a php script into typoscript

I want to include the output of a php script into typoscript, using a lib-object... I miserably fail :) 我想使用一个lib对象将一个php脚本的输出包含到typoscript中...我不幸失败了:)

I declare the lib-object like this: 我这样声明lib对象:

TS: TS:

includeLibs.bannerLib = fileadmin/banner/banner.php

lib.banner = USER
lib.banner{
    userFunc = user_banner->user_showBanner
}

Then I need to use a variable(?) to include this in the rest of the TS: 然后,我需要使用变量(?)将其包括在TS的其余部分中:

{f:cObject(typoscriptObjectPath:lib.banner)}

This is most likely where it fails. 这很可能在失败的地方。 I'm not using fluid, but I guess the f:cObject refers to a fluid-template? 我没有使用流体,但是我猜f:cObject是指流体模板吗?

Here's the (very simple) php-script I'm using: 这是我正在使用的(非常简单的)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);

    }
}

What am I doing wrong??? 我究竟做错了什么??? I'm using Typo3 4.6.x 我正在使用Typo3 4.6.x

[EDIT] [编辑]

The page was made by some T3 crack and the whole content is wrapped into some lib-object and then rendered with some kind of lib (I guess). 该页面是由一些T3裂缝制成的,并且整个内容都包裹在一个lib对象中,然后使用某种lib呈现(我猜)。 Here's what it looks like (partly): 这是它的样子(部分):

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>
            )
        }

}

[EDIT 2] [编辑2]

Ok, it's driving me nuts... it really does... 好吧,这真让我发疯...确实如此...

First correction: I'm using Typo3 4.6.x not as stated first 4.7.x 第一次更正:我使用的是Typo3 4.6.x,而不是前面提到的4.7.x

I try to include the userFunc in typoscript, but it refuses to spit out anything. 我试图将userFunc包含在打字稿中,但它拒绝吐出任何东西。 The PHP-Function (class) from above remains the same. 上面的PHP函数(类)保持不变。 The function within the class isn't called at all. 类中的函数根本没有被调用。

In typoscript I tried: 在打字稿中,我尝试过:

1st attempt: 第一次尝试:

includeLibs.user_banner = fileadmin/banner/user_banner.php

lib.myBanner = USER_INT
lib.myBanner{
    userFunc = user_banner->user_showBanner
}

page.100000 < lib.myBanner

No output whatsoever 无任何输出

2nd attempt: 第二次尝试:

page = PAGE
page.200000 = USER_INT
page.200000.userFunc = user_banner->user_showBanner

again - not output... 再次-不输出...

What on earth am I doing wrong??? 我到底在做什么错???

If you're not using Fluid in your website, this won't produce any output because 如果您未在网站中使用Fluid,则不会产生任何输出,因为

{f:cObject(typoscriptObjectPath:'lib.banner')}

is the inline notation of a Fluid ViewHelper that can only be used in Fluid templates. 是Fluid ViewHelper的内联符号,只能在Fluid模板中使用。

With your TypoScript and the userFunc, you will have the return value of showBanner available in lib.banner. 使用TypoScript和userFunc,您将在lib.banner中获得showBanner的返回值。 You just need to display it somewhere on the website. 您只需要将其显示在网站上的某个位置即可。

If you have a PAGE object in your website, you can add it to your page as follows: 如果您的网站中有PAGE对象,则可以如下将其添加到页面中:

page.20141031 < lib.banner

(Where 20141031 is a unique number that is not used for another part of your PAGE object yet.) (其中20141031是唯一编号,尚未用于PAGE对象的另一部分。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM