dousilie9522 2014-10-31 09:22
浏览 39

将php脚本中的内容包含在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???

  • 写回答

1条回答 默认 最新

  • duandaodao6951 2014-10-31 11:43
    关注

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

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据