[TYPO3-templavoila] Passing FCE field value to userFunc as parameter

Frédéric Ollivier lordef at gmail.com
Sat Mar 21 17:51:41 CET 2009


Hi
This is exactly what I'd like to do. Thanks a lot !

When I try your demo, userFunc is not processed. Where do I put it ? I send
it at fileadmin root.

Fredol

2009/3/20 Dmitry Dulepov <dmitry at typo3.org>

> Hi again!
>
> Dmitry Dulepov wrote:
> > Frédéric Ollivier wrote:
> >> I've created a FCE with a field named SKU.
> >>
> >> In FE, I need to display an image based on this SKU.
> >>
> >> I thought I could access SKU field using TypoScript in my Setup and pass
> it
> >> to a userFunc but this does not work.
> >
> > Yes, you can do it. For example, content elements are fetched this way.
> Here is TS for the content elements that TemplaVoila generates:
> >
> > 10 = RECORDS
> > 10.source.current=1
> > 10.tables = tt_content
> >
> > Try dumping $this->cObj->data and see what you got there.
>
> I just made a demo of it. My user function looks like:
>
> ===================
> <?php
>
> class user_testfunc {
>
>        function main($content, $conf) {
>                return $this->cObj->stdWrap($content, $conf['stdWrap.']);
>        }
>
> }
>
> ?>
> ====================
>
> DS looks like:
> ====================
> <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
> <T3DataStructure>
>        <meta type="array">
>                <langDisable>1</langDisable>
>        </meta>
>        <ROOT type="array">
>                <tx_templavoila type="array">
>                        <title>ROOT</title>
>                        <description>Select the HTML element on the page
> which you want to be the overall container element for the
> template.</description>
>                </tx_templavoila>
>                <type>array</type>
>                <el type="array">
>                        <field_1 type="array">
>                                <tx_templavoila type="array">
>                                        <title>Field 1</title>
>                                        <sample_data type="array">
>                                                <numIndex
> index="0"></numIndex>
>                                        </sample_data>
>                                        <eType>input</eType>
>                                        <proc type="array">
>                                                <stdWrap></stdWrap>
>                                                <HSC type="integer">1</HSC>
>                                        </proc>
>                                </tx_templavoila>
>                                <TCEforms type="array">
>                                        <label>Field 1</label>
>                                        <config type="array">
>                                                <type>input</type>
>                                                <size>48</size>
>                                                <eval>trim</eval>
>                                        </config>
>                                </TCEforms>
>                        </field_1>
>                        <field_2 type="array">
>                                <tx_templavoila type="array">
>                                        <title>Field 2</title>
>                                        <sample_data type="array">
>                                                <numIndex
> index="0"></numIndex>
>                                        </sample_data>
>                                        <eType>none</eType>
>                                        <TypoScript><![CDATA[
> 10 = USER
> 10 {
>    userFunc = user_testfunc->main
>    stdWrap.field = field_1
>    stdWrap.noTrimWrap = |The value of field_1 is: ||
> }
> ]]></TypoScript>
>                                        <proc type="array">
>                                                <stdWrap></stdWrap>
>                                        </proc>
>                                </tx_templavoila>
>                        </field_2>
>                </el>
>        </ROOT>
> </T3DataStructure>
> ====================
>
> It works well. You get t3d export and PHP file at
> http://privatepaste.com/download/3bwjjbn11Q
>
> Is this what you were looking for?
>
> --
> Dmitry Dulepov
> TYPO3 core team
>
> http://dmitry-dulepov.com/article/typo3-extension-update-google-sitemap.html
> _______________________________________________
> TYPO3-project-templavoila mailing list
> TYPO3-project-templavoila at lists.netfielders.de
>
> http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-project-templavoila
>


More information about the TYPO3-project-templavoila mailing list