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

Dmitry Dulepov dmitry at typo3.org
Fri Mar 20 21:30:15 CET 2009


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


More information about the TYPO3-project-templavoila mailing list