[Cartoweb-users] MyFirst Plugin]

Milo van der Linden mlinden at zeelandnet.nl
Sun Aug 12 18:43:49 EDT 2007


Wow,

Thank you for the fast response on a sunday evening! Seems I am not the
only addict here ;-)

I indeed meant the cartoclient.tpl, correct.
I do not need an ini just yet, I just want to let cartoweb display this
plugin template content for me. I took over a project from a guy doing
an internship. He messed things up a bit by hacking into the highest
directories for cartoweb. I am trying to do it right this time.

I have now changed my ClientprojectSelect.php (name of my plugin) to
<?php
class ClientprojectSelect extends ClientPlugin
{
protected function drawprojectSelect() {
    $smarty = new Smarty_Plugin($this->getCartoclient(), $this);
    return $smarty->fetch('projectSelect.tpl');
}

public function renderForm(Smarty $template) {
     $projectSelect_active = $this->getConfig()->projectSelectActive;
     $template->assign(array('prjectSelect_active' =>
$projectSelect_active));
     if ($projectSelect_active)
         $template->assign('projectSelect', $this->drawprojectSelect());
    }
}

?>


All I want it to do is display the content of the tpl, but now I am
getting headers not sent info..

Please see the error messages I am getting now:
http://82.176.214.209/cartoweb/webGIS.php

What am I doing wrong?

Yves Jacolin schreef:
> Le dimanche 12 août 2007 18:45, Milo van der Linden a écrit :
>   
>> Hello list,
>>
>> I am trying to write a simple, static plugin that displays a dropdownbox
>> on the cartoweb GUI, for now it doesn't have to do anything. I just want
>> to check if I am capable of taking the first steps in writing plugins.
>>
>> I did the following:
>>
>> I created the required directories:
>>
>> <myProject>/plugins/myplugin
>> <myProject>/plugins/myplugin/client
>> <myProject>/plugins/myplugin/templates
>>
>> in client I created a file Clientmyplugin.php
>> in templates I created a file myplugin.tpl
>>
>> In the myplugin.tpl I have the following code:
>>
>> <div id="mypluginSelect">
>> <SELECT NAME="myplugin_select">
>> <OPTION VALUE="">
>> <OPTION VALUE="1"> Project 1
>> <OPTION VALUE="2"> Project 2
>> <OPTION VALUE="3"> Project 3
>> </SELECT>
>> </div>
>>
>> As you can see, it is very static.
>>
>> In Clientmyplugin.php I have the following code:
>>
>> class Clientmyplugin extends ClientPlugin
>> implements Sessionable, GuiProvider
>> {
>>
>>     /* here comes your plugin client class definition */
>>
>> }
>>
>>
>> In the client.ini.in; I added myplugin to the loadplugins= line
>>
>> In my customized cartoclient.php I added
>>
>> {if $myplugin_active|default:''}
>>    {$myplugin}
>>    {/if}
>>
>> As you can see, I just want cartoclient to load the dropdown when it
>> starts up.
>>
>> Problems I run in to:
>>
>> - Setting the activation parameter for a plugin in cartoclient.php is
>> not documented
>> - A simple method in the client to parse the template to cartoclient.php
>> is not documented
>>
>> Is there anybody that can help me with these simple steps?
>>     
> Hi,
>
> First of all, I think you mean cartoclient.tpl instead of cartoclient.php ;)
>
> A simple methode to parse the template could be something like : 
>    /**
>     * @see GuiProvider::renderForm()
>     */
>     public function renderForm(Smarty $template) {
>         // authentification
>         $editRoles = $this->getArrayFromIni('general.allowedRoles', true);
>         $allowed = SecurityManager::getInstance()->hasRole($editRoles);
>         $smarty = new Smarty_Plugin($this->getCartoclient(), $this);
>         $smarty->assign(array('manager_allowed' => $allowed,
>                         'layersManagerMessage' => $this->Message));
>         $template->assign('layersManager', 
> $smarty->fetch('layersManager.tpl'));
>     }
> /************************************
> 'layersManager' was the name of the plugin where I took this function.
> 'manager_allowed' and 'layersManagerMessage' are two variable you can send to 
> the template file via smarty function  (assign function first define some 
> variable you can use into the template file then it assign variable to the 
> template file)
>
> You will need this function :
>     /**
>      * Returns an array from a comma-separated list of a ini parameter.
>      * @param string name of ini parameter
>      * @param boolean (default: false) true: returns a simplified array
>      * @return array
>      */
>     protected function getArrayFromIni($name, $simple = false) {
>         $data = $this->getConfig()->$name;
>         if (!$data) return array();
>
>         return $this->getArrayFromList($data, $simple);
>     }
>
> Which allow you to get parameter from your myPlugin.ini file (don't seem you 
> need it yet ;) 
>
> Hope this will help you. You can drop an eye to the cw3 plugins to get some 
> information. If you read the french, you can drop an eye as well to the 
> cartoweb-community?net, documentation chapter, I begin to write something 
> about developing a plugin ionto cw3.
>
> Finally, I don't understand this :
>   
>> - Setting the activation parameter for a plugin in cartoclient.php is
>> not documented
>>     
>
> Regards,
>
> Y.
>   

-- 


	

Milo van der Linden
skype: milovanderlinden <skype:milovanderlinden?add>
mlinden at zeelandnet.nl <mailto:mlinden at zeelandnet.nl>
milovanderlinden at gmail.com <mailto:milovanderlinden at gmail.com>
milo at 3dsite.nl <mailto:milo at 3dsite.nl>
http://www.3dsite.nl

	  	

De informatie in dit bericht reflecteert mijn persoonlijke mening en
niet die van een bedrijf of instantie. Aan de informatie kunnen geen
rechten worden ontleend. Indien dit bericht onderdeel is van een forum,
mailing-list of community dan gelden automatisch de bij het betreffende
medium behorende voorwaarden. The information in this message reflects
my personal opinion and not that of a company or public body. All rights
reserved.If this message is contained in a mailing-list or community,
the rights on the medium are automatically adapted.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/cartoweb-users/attachments/20070813/206c8b4e/attachment.html


More information about the Cartoweb-users mailing list