Search code examples
mysqltypo3typoscripttypo3-8.x

Reading TYPOscript fe_users does not work within a COA


I have just the following problem, I would like to spend via TYPOScript a specific FE_user in the template, only this does not work, is there a restiktives SQL statement or I use here what wrong? Maybe it's the nesting?

Here is the code:

lib.contactPasswords = COA
lib.contactPasswords.10 = TEXT
lib.contactPasswords.10.value (
    <p>User: Safari</p>
)
lib.contactPasswords.20 = CONTENT
lib.contactPasswords.20 {
    table = fe_users
    select {
        max = 1
        pidInList = 173
        andWhere = username = 'Safari'
    }
    renderObj = COA
    renderObj
    {
        10 = TEXT
        10.field = username
        wrap =|<br / >
    }
}
lib.contactPasswords.20.wrap = <div>User: |</div>

And the output is the same like:

<p>User: Safari</p>
<div>User:</div>

Desired result:

<p>User: Safari</p>
<div>User: Safari</div>

Can someone explain to me where the mistake is, why the content remains empty?

More Information:

  • TYPO3 Version: 8.7.19
  • Using like: <f:cObject typoscriptObjectPath="lib.contactPasswords" /> in Fluid Template
  • And yes: The User "Safari" exist in the database :)

Solution

  • Are you sure the username is Safari? Usernames are usually all lowercase in TYPO3. If you added it through the backend it will be cast to lowercase. So it would be safari.

    You should not have an enter between cObject and {. It should be cObject {

    Also andWhere is deprecated since TYPO3 7.1 and removed in TYPO3 8.7. You should use where instead.

    For me, this works:

    lib.contactPasswords.20 = CONTENT
    lib.contactPasswords.20 {
      table = fe_users
      select {
        max = 1
        pidInList = 173
        where = username = 'safari'
      }
      renderObj = COA
      renderObj {
        10 = TEXT
        10.field = username
        wrap = |<br / >
      }
    }