Search code examples
typo3typoscriptfluid

TypoScript select where dataWrap dynamically filled by fluid variable possible?


I have my own extension with which a frontend user can create own records. On a user detail page then all entries of the user should be displayed.

In my "Show" template I have a variable {user.uid} with which I come to the User UID. How do I get that into my typoscript?

Typoscript

lib.getuserItems = CONTENT
lib.getuserItems {
table = tx_myext_domain_model_item
select {
    selectFields = crdate,image,message,uid,deleted
    pidInList = 2
    orderBy = crdate DESC
    where.data = 
    where.dataWrap = ((tx_myext_domain_model_item.author_ident = '{user.uid}')) AND deleted = 0 AND NOT tx_myext_domain_model_item.parent_item
}

Fluid

<f:cObject typoscriptObjectPath="lib.getuserItems" data="{user.uid}" />

Solution

  • If your data is a single value (so not an array or object), it is available as the current value in TypoScript. So your TypoScript should be:

    lib.getuserItems = CONTENT
    lib.getuserItems {
      table = tx_myext_domain_model_item
      select {
        selectFields = crdate,image,message,uid,deleted
        pidInList = 2
        orderBy = crdate DESC
        where.current = 1
        // ensure it's an integer
        where.intval = 1
        where.wrap = ((tx_myext_domain_model_item.author_ident = '|')) AND deleted = 0 AND NOT tx_myext_domain_model_item.parent_item
      }
    }