[TYPO3-english] retrieve IDs of content items in FCE?

Torsten Schrade schradt at uni-mainz.de
Sun Nov 11 22:01:01 CET 2012


Hello again Erich,

> Thank you for the reply, Torsten.  The problem with that solution is that
> each time a user copies a page with the FCE on it, I believe the copy will
> have a new ID so the typoscript won't be looking at the new copy of the FCE.
> 
> Is there another way to access the IDs of content items within an FCE on a
> page - perhaps by field name rather than ID of the FCE?

No problem, you can make use of the stdWrap capabilities of XPATH's
source property and retrieve the FCE id dynamically with a CONTENT cObject:

page.10 = XPATH
page.10 {

  # fetch XML field from FCE on current page
  source.cObject = CONTENT
  source.cObject {
    table = tt_content
    select {
      where = CType='templavoila_pi1'
      andWhere = tx_templavoila_ds=###FCE_DS_ID###
      max = 1
      selectFields = tx_templavoila_flex
    }
    renderObj = TEXT
    renderObj.field = tx_templavoila_flex
  }

  # set expression and return format
  expression = //field[@index="###YOUR_FIELDNAME###"]/value
  return = string

  # result object from XPATH query
  resultObj {
    cObjNum = 1
    1.current = 1
  }
}

Since the scope of the CONTENT cObject is always the current page (if
not set otherwise with pidInList) you always get the first FCE on your
(copied) pages. The andWhere part above is optional but helps in
narrowing down the possible results to a specific FCE type. If that is
not enough, try to find the FCE type you are targeting with phpMyAdmin
in the table tt_content and check which fields you could use in your
specific setup to only select FCEs you want.

Cheers,
Torsten


More information about the TYPO3-english mailing list