简体   繁体   English

如何在Typoscript中使用Fluid cObject数据

[英]How to use Fluid cObject data in Typoscript

I have following fluid script to insert a typoscript lib: 我有以下流畅的脚本,可插入一个排字库:

<f:cObject typoscriptObjectPath="lib.artteaser" data="{imgclass: 'img-cover'}"/>

I want to use the "data" parameter in a typoscript within FILES.renderObj for the wrap as a css class - the following is what I've tried so far, but it didnt work. 我想在FILES.renderObj的打字稿中使用“数据”参数作为css类进行换行-到目前为止,以下是我已经尝试过的操作,但是没有用。

lib.artteaser = COA
lib.artteaser {

    wrap = <section><div class="container"><div class="row cover-teaserbox">|</div></div></section>

    10 = CONTENT
    10 {
        table = tt_content
        select {
            [...]
        }

        renderObj = COA
        renderObj {

            wrap = <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 col-xl-3 cover-teaserbox-item">|</div>

            10 = FILES
            10 {

                references {
                    [...]
                }

                renderObj = IMAGE
                renderObj {
                    file.import.data = file:current:uid
                    file.crop.data = file:current:crop
                    file.treatIdAsReference = 1
                    altText.data = file:current:title

                    # the following did not work
                    stdWrap.dataWrap = <div class="cover-teaserbox-item-img {field:imgclass}">|</div>

                    stdWrap.typolink {
                        parameter.field =  pid
                    }
                }

                maxItems = 1

            }

            [...]

        }

    }

}

Can somebody give me a hint to get this to work? 有人可以给我一个提示使其工作吗? Thank you in advance! 先感谢您!

Everytime you use current or field:* or data = * you need to consider context. 每次使用currentfield:*data = *都需要考虑上下文。

On entering your TS object you have all your 'parameters' as current context. 输入TS对象时,会将所有“参数”作为当前上下文。 but as soon as you build a menu or work on records ( CONTENT ) the single record (page record in case of menus) is the current context. 但是一旦构建菜单或处理记录( CONTENT ),则单个记录(在菜单情况下为页面记录)就是当前上下文。

In your case you can store your parameter to a register and use it later. 在您的情况下,您可以将参数存储到寄存器中并在以后使用。

lib.artteaser = COA
lib.artteaser {

    5 = LOAD_REGISTER
    5 {
        imageClass.field = imgclass
    }

    10 = CONTENT
    10 {
           :
           :
               stdWrap.dataWrap = <div class="cover-teaserbox-item-img {register:imageClass}">|</div>
           :
           :
    }
}

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

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