0
votes

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

1
What do you mean by "I'm not using Fluid"? You cannot use a Fluid ViewHelper outside a Fluid template. If you are in a FLUIDTEMPLATE context, try wrapping lib.banner in single quotes. BTW, you could use a pure TypoScript solution to achieve this.lorenz
So, the {...} part is a Fluid ViewHelper? Bear with me - I'm new to T3 and utterly confused :) The PHP script is just a fragment to test if I can get some values out of it - it'll be bigger in the end. So «pure TS» is most likely not what I'm aiming for. So - again: I just need to pack the output of the PHP-script into a TS variable. That can't be that hard, can it? Google doesn't deliver any useable results, hence my question on SO ;)Swissdude

1 Answers

0
votes

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