[TYPO3-project-formidable] Dynamically pass the cruser_id to the SQL of the datasource

Ian Solo ian at webian.it
Fri May 9 14:23:42 CEST 2008


Thank you so much Manuel!
It works like a sharm. =)

Best regards!ian

Manuel Rego Casasnovas wrote:
> Hi,
> 
> On Thu, 2008-05-08 at 11:45 +0200, Ian Solo wrote:
>> I have a renderlet:LISTER that get the data from this datasource:
>> *****************************************************************
>> <datasources>
>> 	<datasource:DB name="images">
>> 		<sql><![CDATA[
>> 			SELECT	uid, image, title, tstamp, crdate
>> 			FROM	tx_iangallery_gallery
>> 			WHERE	pid = 301
>> 			AND	cruser_id = 81
>> 			AND	deleted=0
>> 			AND	hidden=0
>> 		]]></sql>
>> 	</datasource:DB>
>> </datasources>
>> *****************************************************************
>>
>> How can I dynamically pass the cruser_id of the current user logged to 
>> this SQL?
> 
> You can use an userobj that return the SQL query from a function:
> <datasource:DB name="images">
>    <sql>
>       <userobj>
>          <extension>this</extension>
>          <method>_generateSQL</method>
>       </userobj>
>    </sql>
> </<datasource:DB>
> 
> or directly from PHP:
> <datasource:DB name="images">
>    <sql>
>       <userobj>
>          <php>
>             <![CDATA[
>                $cruserId = 81;
>                return 'SELECT  uid, image, title, tstamp, crdate
>                   FROM    tx_iangallery_gallery
>                   WHERE   pid = 301
>                   AND     cruser_id = ' . $cruserId . '
>                   AND     deleted=0
>                   AND     hidden=0';
>                 ]]>
>          </php>
>       </userobj>
>    </sql>
> </<datasource:DB>
> 
> Best regards,
>    Rego
> 


More information about the TYPO3-project-formidable mailing list