简体   繁体   中英

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

I declare the lib-object like this:

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:

{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?

Here's the (very simple) php-script I'm using:

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

[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). 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]

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

I try to include the userFunc in typoscript, but it refuses to spit out anything. The PHP-Function (class) from above remains the same. 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

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

is the inline notation of a Fluid ViewHelper that can only be used in Fluid templates.

With your TypoScript and the userFunc, you will have the return value of showBanner available in lib.banner. 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.20141031 < lib.banner

(Where 20141031 is a unique number that is not used for another part of your PAGE object yet.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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