[Cartoweb-users] Using the selected object in the layer in my
own plugin
Alexandre Saunier
alexandre.saunier at camptocamp.com
Thu Oct 6 11:53:33 EDT 2005
Eduard,
>> $xml = "<gisdata>";
>> foreach ($tableGroups->group as $group) {
>> foreach ($tableGroup->tables as $table) {
>> if($table->numRows > 0){
>> $xml .= "<layer name=" . $table->tableTitle . ">";
>> $xml .= "<meta>";
>>
>> [...]
>>
>> $xml = "</gisdata>";
First, the above code seems perfectly fine but you may also use Smarty
to generate your XML code (which is in fact not really different from
HTML code!). In CartoWeb CVS version, we have done so in
client/Views.php. For instance in ViewFileContainer::writeXmlContent()
$smarty = new Smarty_Cartoclient($this->cartoclient);
$smarty->assign(array('charset' => Encoder::getCharset(),
'metas' => $this->metas,
'sessionData' => $data,
));
return $smarty->fetch('view.xml.tpl');
associated to a dedicated XML template file view.xml.tpl.
That was just a tip. ;)
> The problem is that i dont know how i should access this $tableGroups,
> which is stored inside the ClientTables.php (private). I know that the
> value is also assigned to Smarty under the key='tables', but i also dont
> know how to access it.
I presume you use CartoWeb3.0.
In CVS version there is a public method ClientTables::getTableGroups()
which is missing in 3.0.0.
If you prefer to keep using CW3.0, a solution would be to extend the
tables plugin in your project and add this method in your extended class
(see
http://cartoweb.org/doc/xhtml/dev.newplugin.html#dev.newplugin.adapting.extending)
Obviously you'll have to switch ClientTables::tableGroups from private
to protected in the ClientTables.php upstream code. It's not a big deal
since it does not affect the class behavior much.
By the way note that in CVS version, most plugins private methods and
members have recently been switched to protected (including
ClientTables::tableGroups) in order to make plugin extending easier.
Hope this helps,
AS
More information about the Cartoweb-users
mailing list