Matija Milković
Matija Milković

Reputation: 2458

TYPO3 / TemplaVoila DB relation between two content elements

enter image description here

So I'm doing a custom user function(php script) in TYPO3 cms, I'm fetching data with sql, what I'm trying to do is fetch all of the content from one page.

I can easily do that by fetching data from tt_content with pid of the page, but what is the db relation between say that one plugin content elemenet(element under 1 in picture) and text&img content element (element under 2 in picture)?

How do I link them in DB so I know that they are both under Google map container?

Many thanks!

Upvotes: 0

Views: 338

Answers (1)

biesior
biesior

Reputation: 55798

TemplaVoila stores tt_content uids (and their order) in table pages - in field tx_templavoila_flex, it's standard XML

To fetch all elements from given page you need to fetch that XML and read value with vDEF index from required column (as a common XML node). Uid's of tt_content elements are comma divided, so when you'll read ths node you just need to use explode by comma to get an array in proper order. sample:

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3FlexForms>
   <data>
       <sheet index="sDEF">
           <language index="lDEF">
               <field index="field_leftcolumn">
                   <value index="vDEF">284,190,221</value>
               </field>
               <field index="field_rightcolumn">
                   <value index="vDEF">134,130</value>
               </field>
            </language>
       </sheet>
   </data>
</T3FlexForms>

You can check how to work with these XML structures in... TemplaVoila source code, for an example it's probably easiest to convert the XML to PHP array:

$flexformContentArr = t3lib_div::xml2array($row['tx_templavoila_flex']);

@see: typo3conf/ext/templavoila/class.tx_templavoila_api.php line #1362

Upvotes: 1

Related Questions