[TYPO3-english] XPATH content object question

erich at erichspecht.com erich at erichspecht.com
Thu Nov 29 00:40:51 CET 2012


I've had some success with what Torsten suggested in the thread below, but
only when I try to output the value from a flexform field to the page
object.  When I try to write it to a typoscript object path, I'm not
seeing any results.

Here's the code I'm using:

temp.myvar = XPATH
temp.myvar {

  # 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=128
      max = 1
      selectFields = tx_templavoila_flex
    }
    renderObj = TEXT
    renderObj.field = tx_templavoila_flex
  }

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

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

#if I uncomment the next line, it displays the proper result, but it isn't
applying it to lib.field_tier2_2
#page.10 < temp.myvar
lib.field_tier2_2 >
lib.field_tier2_2 = COA
lib.field_tier2_2.10 < temp.myvar

Please let me know if you have any suggestions on what I'm doing wrong.

Thanks again for the help.

Erich

-----Original Message-----
From: typo3-english-bounces at lists.typo3.org
[mailto:typo3-english-bounces at lists.typo3.org] On Behalf Of Torsten
Schrade
Sent: Sunday, November 11, 2012 3:01 PM
To: typo3-english at lists.typo3.org
Subject: Re: [TYPO3-english] retrieve IDs of content items in FCE?

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
_______________________________________________
TYPO3-english mailing list
TYPO3-english at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english




More information about the TYPO3-english mailing list