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

Torsten Schrade schradt at uni-mainz.de
Sat Nov 10 23:10:26 CET 2012


Hi Erich,

> Is it possible via typoscript to retrieve the unique IDs of tt_news records
> that are placed into an FCE?
> 
> For example, I have a Flexible Content Element that contains a field of type
> Page Content Elements that allow the user to choose tt_news records.  From
> typoscript on the main page, can I retrieve the ID of the article that was
> selected in that field?

Yes, you can do that using the XPATH cObj. Check out the tutorial on how
to get values from a tt_content flexform:

http://typo3.org/extensions/repository/view/cobj_xpath
http://typo3.org/extension-manuals/cobj_xpath/1.1.1/view/1/4/#id547457

Its basically the same for FCEs since they also store their values in
XML. You may adapt the following snippet to your structure:

lib.xpath = XPATH
lib.xpath {
  source.data = DB : tt_content:###YOUR_FCE_ID###:tx_templavoila_flex
  return = string
  expression = //field[@index="###YOUR_FIELDNAME###"]/value
  resultObj {
    cObjNum = 1
    1.current = 1
  }
}

Have fun,
Torsten


More information about the TYPO3-english mailing list