[TYPO3-dev] set_no_cache is bad. What's next?

JoH asenau info at cybercraft.de
Sat Oct 31 10:04:05 CET 2009


>>>> IMHO this is how most of the extensions should be working and this
>>>> is how tt_products, tt_news and the like could be tuned to work
>>>> much faster than they currently do.
>>> Yes, this seems to be a good solution for the single view. But how
>>> should this work for the list view of products, where you also have
>>> a category header and sorting of products? All products of a
>>> category are listed together in their own block. You have a basket
>>> part as USER_INT for each product on the list view.
>>
>> Yes - and where is the problem?
>> Although I have to admit that it might be faster to render the whole
>> list as a USER_INT in this case.
>> But anyway it will be better than using set_no_cache()
>>
>> So again - where is the problem?
>
> In the tt_products list view you have these parts:
>
> [snip]
>
> Which setup must I use to have also the whole list view as a wingle
> cObject? There are multiple parts repeated inside of another subpart
> marker. Can you still build this with a TEMPLATE setup?

Yes we can! ;-)

> How do you
> build these repeated parts described by subpart markers and the
> wrapped subpart markers for the links?

I use a combination of USER/USER_INT with a renderObj using a TEMPLATE and
workOnSubPart.
renderObj is just a name I use, since it is working similar to the official
renderObj of CONTENT objects.

Just an example, not complete but it shows how to do it with a nested
TEMPLATE, COA and USER-structure.
Within this structure you can easily switch from COA to COA_INT or USER to
USER_INT.

listView = TEMPLATE
listView {
  template = FILE
  template.file = mytemplate.html
  subparts {
    FE_GROUP_1_TEMPLATE = COA
    FE_GROUP_1_TEMPLATE {
      10 = USER
      10 {
        userFunc = myExtension->feGroupFunction
        renderObj = TEMPLATE
        renderObj {
          file = mytemplate.html
          workOnSubPart = FE_GROUP_1_TEMPLATE
          subparts {
            #blah
          }
          marks {
            #blah
          }
        }
      }
    }
    #
    # Same for other subparts as well
    # LINK_BROWSE, LINK_NEXT
    #
    ITEM_CATEGORY_AND_ITEMS = COA
    ITEM_CATEGORY_AND_ITEMS {
      10 = USER
      10 {
        userFunc = myExtension->itemCategoryAndItemFunction
        renderObj = TEMPLATE
        renderObj {
          template = FILE
          template.file = mytemplate.html
          workOnSubPart = ITEM_CATEGORY_AND_ITEMS
          subparts {
            ITEM_CATEGORY = COA
            ITEM_CATEGORY {
              10 = USER
              10 {
                 userFunc = myExtension->itemCategoryFunc
                 renderObj = SOMETHING
            }
            ITEM_LIST = COA
            ITEM_LIST {
              10 = USER
              10 {
                userFunc = myExtension->itemListFunc
                renderObj = TEMPLATE
                renderObj {
                  template = FILE
                  template.file = mytemplate.html
                  workOnSubPart = ITEM_LIST
                  subparts {
                    ITEM_SINGLE = COA
                    ITEM_SINGLE {
                      10 = USER
                      10 {
                        userFunc = myExtension->singleItemFunc
                        renderObj = TEMPLATE
                        renderObj {
                          template = FILE
                          template.file = mytemplate.html
                          workOnSubPart = ITEM_SINGLE
                          marks {
                            PRODUCT_TITLE = TEXT
                            PRODUCT_TITLE.field = blah
                            PRODUCT_IMAGE1 = IMAGE
                            PRODUCT_IMAGE1 {
                                #blah
                            }
                          }
                          subparts {
                            ITEM_SINGLE = COA
                            ITEM_SINGLE {
                              10 = USER
                              10 {
                                userFunc = myExtension->singleItemFunc
                                renderObj = SOMETHING
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

Since most of the stuff can be cached, the possible performance issues
raised by nested TypoScript objects and stdWrap function calls only slow
down the first run.
As you can see, this structure works just like the main() function of a
usual plugin. It separates the different parts and calls the necessary
functions.
This is why the main() function of this structure just has to call
cObjGetSingle together with this TypoScript-Setup.

I use an additional COA for each subpart to make sure that admins can easily
add other stuff as well.
i.e. it would be a nobrainer to fill in a tagcloud for each single item just
with some lines of TypoScript:

listView.subparts.ITEM_CATEGORY_AND_ITEMS {
  10.renderObj.subparts.ITEM_LIST {
    10.renderObj.subparts.ITEM_SINGLE {
      5 = COA_INT
      5 {
        10 < plugin.tx_tagpack_pi1
        10 {
           #tagcloudsetup
        }
      }
    }
  }
}

If more people would use TypoScript in a similar way instead of abusing it
as a container for a set of parameters for their PHP functions, many
extensions would be much more flexible, usable and thus powerful.

HTH

Joey

-- 
Wenn man keine Ahnung hat: Einfach mal Fresse halten!
(If you have no clues: simply shut your gob sometimes!)
Dieter Nuhr, German comedian
Xing: http://contact.cybercraft.de
Twitter: http://twitter.com/bunnyfield
TYPO3 cookbook (2nd edition): http://www.typo3experts.com






More information about the TYPO3-dev mailing list