[TYPO3-project-formidable] xmlbuilder and dynamic datasource (am I using the right)
Christian Ruppert
typo3lists at cruppert.de
Tue Jul 8 12:51:32 CEST 2008
Hello,
first of all, thanks, really a great library. And now my question, am I
on the right track:
I want to do AS LITTLE AS POSSIBLE in the XML file, and most of the
configuration directly in the PHP. So I already discovered a way to
include a datasource from PHP like this:
------------------------------------------------------------------
<datasource:PHPARRAY name="getPagesListData">
<bindsto>
<userobj>
<php>
<![CDATA[
return
$this->_oParent->deliverDataSource('getPagesListData');
]]>
</php>
</userobj>
</bindsto>
</datasource:PHPARRAY>
------------------------------------------------------------------
The obvious disadvantage of the approach above is: The name of the
datasource is coded "hard" inside the XML. So, I want MORE....
My next idea, which work pretty good, is to use the xmlbuilder. So
instead of creating 18 datasources (where I dont even know if I need
them) i just include one XML buider and let the code generate the
datasources:
XML CODE
------------------------------------------------------------------
<xmlbuilder>
<userobj>
<php>
<![CDATA[
return $this->_oParent->deliverDatasourceXML();
]]>
</php>
</userobj>
</xmlbuilder>
------------------------------------------------------------------
and in the PHP file
------------------------------------------------------------------
function deliverDatasourceXML() {
return array(
"datasource" => array ("type" => "PHPARRAY",
"name" => "getPagesListData",
"bindsto" => array("userobj" =>
array("php" =>
'return $this->_oParent->deliverDataSource("");
')),),);}
------------------------------------------------------------------
Sorry for the indent, it horrible but my reader has a 70 something limit..
Now my question: Does anybody know how to improve the ugly "passing the
php as string for eval". See the last example, there is a array which
has a string which points to the parent which executes a function. Is
there a way to pass the data of the funtion directly to the datasource...
Or even a better question, how (or where) do I get Informations about
the different options, all handlers, datasources and stuff. The wiki is
ok, but not really a reference. And the API is more PHP focussed, not
really all possible XML options. Or at least I dont find them...
Any tips welcome...
Christian
PS: Even if nobody answers, I think the examples above are quite useful
for newbies. With a bit of tricks you can strip down the XML to a few
lines, like this (not tested yet)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<formidable version="1.0.182">
<meta>
<xmlbuilder>
<userobj><php>
<![CDATA[
return $this->_oParent->deliverMetaXML('');
]]>
</php></userobj>
</xmlbuilder>
</meta>
<control>
<xmlbuilder>
<userobj><php>
<![CDATA[
return $this->_oParent->deliverControlXML('');
]]>
</php></userobj>
</xmlbuilder>
</control>
<elements>
<xmlbuilder>
<userobj><php>
<![CDATA[
return $this->_oParent->deliverElementsXML('');
]]>
</php></userobj>
</xmlbuilder>
</elements>
</formidable>
More information about the TYPO3-project-formidable
mailing list