typo3typoscripttypo3-9.x

TYPO3 CONTENT select pass Argument to USER/USER_INT


typoscript:

lib.category = CONTENT
lib.category {
  table=sys_category
  select {
    pidInList = root
    selectFields = sys_category.*
    join = sys_category_record_mm ON sys_category_record_mm.uid_local = sys_category.uid
    where.field = sys_category_record_mm.uid_foreign = data.uid
    languageField = 0
  }
  renderObj = USER_INT
  renderObj {
    userFunc = InstantAitExt\AitContacts\GetPageCategories->testExecute
    alias = TEXT
    alias.value = data.uid
  }
}

I have to pass 1-x arguments to testExecute. one of those parameters should hold the uid of a given page. this uid gets passed to lib.category=CONTENT via

<f:cObject typoscriptObjectPath="lib.category" data="{page}" />

so data.uid is basically page.data.uid

thing is if i pass data.uid to alias.value the argument holds data.uid as a string and not the actual value i need.

so how is it possible to pass the actual pageId to alias.value

also, the query works but i am not able to verify/debug

where.field = sys_category_record_mm.uid_foreign = data.uid

to check if the query really gets the correct value (page id from view)


Solution

  • you can't debug it as it is an syntax error.

    the attribute is where and if you use where.field you want to set the value from a field (of current context). after the equal sign the name of a field is expected.

    But you give an expression sys_category_record_mm.uid_foreign = data.uid. That can't be evaluated.

    What you want is an expression with a data. this data should be replaced.
    So you either use a wrap for the replaced data (or field)

    where.data = data.uid
    where.wrap = sys_category_record_mm.uid_foreign = |
    

    which is equal to

    where.field= uid
    where.wrap = sys_category_record_mm.uid_foreign = |
    

    as data is the current context, so you can access the field directly.

    or you use an insertData:

    where = sys_category_record_mm.uid_foreign = {data.uid}
    where.insertData = 1
    

    EDIT:

    if you only want to submit the page uid to the typoscript viewhelper you can use
    <f:cObject typoscriptObjectPath="lib.category" data="{page.uid}" /> or a simple array like:
    <f:cObject typoscriptObjectPath="lib.category" data="{uid:page.uid}" />

    while the second call would not change the typoscript above (you only have a smaller data array which contains only the field uid while the original call contains the whole pages record).

    For the viewhelper with just the uid value you have to use current:

    where = current
    where.wrap = sys_category_record_mm.uid_foreign = |