문제

I have a list of constants assigned to various page IDs (e.g. myConstant = 22). Now I'd love to replace the following link

<f:link.page pageUid="22" >Link</f:link.page>

with something like

<f:link.page pageUid="{myConstant}" >Link</f:link.page>

I haven't been able to find the right syntax to do so. Any help?

도움이 되었습니까?

해결책

i think you can't access the constants directly but you can use the constants in the ts-setup.

with plugin.tx_myplugin.settings.myPid = {$myConstant} in the ts-setup you can access the pid in your plugin with {settings.myPid}

if you're not using a plugin but a TS FluidTemplate you can assign it them like this:

page = PAGE
page {
    10 = FLUIDTEMPLATE
    10 {
        file = fileadmin/templates/Home.html
        variables {
            pidList {
                myConstant = {$myConstant}
                myConstant2 = {$myConstant2}
            }
        }
    }
}

<f:link.page pageUid="{pidList.myConstant}" >Link</f:link.page>

다른 팁

If you are using a FLUIDTEMPLATE typoscript-Object, you can do it as follows in TypoScript:

lib.output = FLUIDTEMPLATE
lib.output {
#   ...
    variables {
        myPageID = {$myConstant}
    }
#   ...
}

In the fluid-template you can use the variables like you want:

<f:link.page pageUid="{myPageID}" >Link</f:link.page>

In case the template is rendered by an extension in a controller action, you can assign the value to a setting of your plugin: plugin.tx_<extkey>[_pi1].settings.myPageID = {$myConstant}. Then you can use it in the fluid template like this:

<f:link.page pageUid="{settings.myPageID}">Link</f:link.page>

In any case, you can assign that value to some TypoScript Object and read that in your template by either using the f:cObject ViewHelper or the v:var.typoscript ViewHelper from the extension vhs.

I tried something like that in t3 7.6 If you want to use a ts constant (defined in ts-constants field as oneConst) somewhere in your page fluid template you must do somthing like this:

page.10 = FLUIDTEMPLATE
page.10 {         
    variables{
        const_one=TEXT
        const_one.value={$oneConst}
        }
    }
}

Without the TEXT definition you will not get the value. Access it in your template:

{const_one} 

Hint: i was not able to organize const in an array. Like

const{
   one=TEXT
   one.value={..}
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top