skip to Main Content

I have 2 COAs: lib.productContent and lib.categoryContent which contain data from a user function.
I also have a third COA – lib.seoColumns – which should contain by default the product COA. If the product COA is empty, it should be overridden by the category COA, but I don’t know how to actually check if the product COA is empty:

########## PRODUCT CONTENT ##########
lib.productContent = COA
lib.productContent {
    10 = USER
    10 {
        userFunc = VendorProviderUserFuncPage->getPageContentByAlias
        alias = TEXT
        alias.data = GP:product
        aliasField.cObject = TEXT
        aliasField.cObject.value = product_alias
    }
}

########## CATEGORY CONTENT ##########
lib.categoryContent = COA
lib.categoryContent {
    10 = USER
    10 {
        userFunc = VendorProviderUserFuncPage->getPageContentByAlias
        alias = TEXT
        alias.data = GP:category
        aliasField.cObject = TEXT
        aliasField.cObject.value = category_alias
    }
}

########## SEO COLUMNS ##########
lib.seoColumns = COA
lib.seoColumns {
    10 < lib.productContent
    10.stdWrap.override.cObject < lib.categoryContent

    # 10.stdWrap.override.if    <-- IF WHAT ?

    wrap = <seoColumns><![CDATA[|]]></seoColumns>
}

2

Answers


  1. Just do it the other way around, since override only will do the actual override, when there is at least something in the overriding object.

    https://docs.typo3.org/typo3cms/TyposcriptReference/Functions/Stdwrap/Index.html#override

    ########## SEO COLUMNS ##########
    lib.seoColumns = COA
    lib.seoColumns {
      10 < lib.categoryContent
      10.stdWrap.override.cObject < lib.productContent
      wrap = <seoColumns><![CDATA[|]]></seoColumns>
    }
    

    no if necessary.

    Login or Signup to reply.
  2. Easiest way would be to use the stdWrap .ifEmpty function
    https://docs.typo3.org/typo3cms/TyposcriptReference/Functions/Stdwrap/Index.html#ifempty

    lib.seoColumns = COA
    lib.seoColumns {
       10. < lib.productContent
       10.stdWrap.ifEmpty.cObject < lib.categoryContent
       wrap = <seoColumns><![CDATA[|]]></seoColumns>
    }
    

    as ifEmpty is of type string/stdWrap it supports stdWrap Attributes and we can use .cObject to load another Content Object. like the COA for the second case.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search