<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>3DSite</TITLE>
<META http-equiv=Content-Type content=text/html;charset=ISO-8859-1>
<META content="MSHTML 6.00.5730.11" name=GENERATOR></HEAD>
<BODY text=#000000 bgColor=#ffffff>
<DIV><FONT color=#000000 size=2>an error occured in your plugin, line
19, and something was outputed very early in the operation flow,
with the result nothing is displayed.</FONT></DIV>
<DIV><FONT color=#000000 size=2></FONT> </DIV>
<DIV><FONT color=#000000 size=2>be sure you dont have a blank space at the
beginning of your plugin code</FONT></DIV>
<DIV><FONT color=#000000 size=2></FONT> </DIV>
<DIV><FONT color=#000000 size=2>first of all, you should user proper naming for
plugin filename and classname, respectively, "ClientProjectSelect.php" and
"class ClientProjectSelect .." (notice the uppercase P), it stay "projectSelect"
in the client.ini</FONT></DIV>
<DIV><FONT color=#000000 size=2></FONT> </DIV>
<DIV><FONT color=#000000 size=2>to simply output something in the main template,
you can do:</FONT></DIV>
<DIV><FONT color=#000000 size=2></FONT> </DIV>
<DIV><FONT color=#000000 size=2>public function renderForm(Smarty $template)
{<BR> $some_variable = 'foo';<BR>
$template->assign('target_name_in_cartoclient_tpl',
$some_variable);<BR>}<BR>and it should display 'foo' where you have
{$target_name_in_cartoclient_tpl} in the cartoclient.tpl</FONT></DIV>
<DIV><FONT color=#000000 size=2></FONT> </DIV>
<DIV><FONT color=#000000 size=2>to load a template from your plugin templates
folder, you need to do as Yves said:</FONT></DIV>
<DIV><FONT color=#000000 size=2></FONT> </DIV>
<DIV><FONT color=#000000 size=2>public function renderForm(Smarty $template)
{<BR></FONT> $smarty = new
Smarty_Plugin($this->getCartoclient(), $this);</DIV>
<DIV> $foo = 'foo';</DIV>
<DIV> $bar = 'bar';</DIV>
<DIV> <FONT color=#000000
size=2>$smarty->assign(array('var1' => $foo, 'var2' => $bar)); // if
you have {$foo} and {$bar} in your plugin template</FONT></DIV>
<DIV><FONT color=#000000 size=2> $plugin_template =
$smarty->fetch('your_plugin_template.tpl');</FONT></DIV>
<DIV><FONT color=#000000 size=2>
$template->assign('target_name_in_cartoclient_tpl', $plugin_template); //
finally pass the whole plugin template to the main
cartoclient.tpl<BR>}</FONT></DIV>
<DIV><FONT color=#000000 size=2></FONT> </DIV>
<DIV><FONT color=#000000 size=2>try the simply example above</FONT></DIV>
<DIV><FONT color=#000000 size=2></FONT> </DIV>
<DIV><FONT color=#000000 size=2>regards</FONT></DIV>
<DIV><FONT color=#000000 size=2>Oliver</FONT></DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=mlinden@zeelandnet.nl href="mailto:mlinden@zeelandnet.nl">Milo van
der Linden</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A
title=cartoweb-users@lists.maptools.org
href="mailto:cartoweb-users@lists.maptools.org">cartoweb-users@lists.maptools.org</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Monday, August 13, 2007 12:43
AM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [Cartoweb-users] MyFirst
Plugin]</DIV>
<DIV><BR></DIV>Wow,<BR><BR>Thank you for the fast response on a sunday
evening! Seems I am not the only addict here <SPAN
class=moz-smiley-s3><SPAN>;-) </SPAN></SPAN><BR><BR>I indeed meant the
cartoclient.tpl, correct.<BR>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.<BR><BR>I have now changed my ClientprojectSelect.php (name of my plugin)
to<BR><?php<BR>class ClientprojectSelect extends
ClientPlugin<BR>{<BR>protected function drawprojectSelect()
{<BR> $smarty = new
Smarty_Plugin($this->getCartoclient(), $this);<BR> return
$smarty->fetch('projectSelect.tpl');<BR>}<BR><BR>public function
renderForm(Smarty $template) {<BR>
$projectSelect_active =
$this->getConfig()->projectSelectActive;<BR>
$template->assign(array('prjectSelect_active' =>
$projectSelect_active));<BR> if
($projectSelect_active)<BR>
$template->assign('projectSelect',
$this->drawprojectSelect());<BR>
}<BR>}<BR><BR>?><BR><BR><BR>All I want it to do is display the content of
the tpl, but now I am getting headers not sent info..<BR><BR>Please see the
error messages I am getting now:<BR><A class=moz-txt-link-freetext
href="http://82.176.214.209/cartoweb/webGIS.php"
moz-do-not-send="true">http://82.176.214.209/cartoweb/webGIS.php</A><BR><BR>What
am I doing wrong?<BR><BR>Yves Jacolin schreef:
<BLOCKQUOTE cite=mid:200708121857.38559.yjacolin@free.fr type="cite"><PRE wrap="">Le dimanche 12 août 2007 18:45, Milo van der Linden a écrit :
</PRE>
<BLOCKQUOTE type="cite"><PRE wrap="">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?
</PRE></BLOCKQUOTE><PRE wrap=""><!---->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 :
</PRE>
<BLOCKQUOTE type="cite"><PRE wrap="">- Setting the activation parameter for a plugin in cartoclient.php is
not documented
</PRE></BLOCKQUOTE><PRE wrap=""><!---->
Regards,
Y.
</PRE></BLOCKQUOTE><BR>
<DIV class=moz-signature>-- <BR>
<STYLE type=text/css>BODY {
        MARGIN: 5px; BACKGROUND-COLOR: #ffffff
}
BODY {
        FONT-SIZE: 12px; COLOR: #333333; FONT-FAMILY: Arial, Helvetica, sans-serif
}
TD {
        FONT-SIZE: 12px; COLOR: #333333; FONT-FAMILY: Arial, Helvetica, sans-serif
}
TH {
        FONT-SIZE: 12px; COLOR: #333333; FONT-FAMILY: Arial, Helvetica, sans-serif
}
.style4 {
        FONT-SIZE: 9px
}
.style5 {
        FONT-SIZE: 9px; COLOR: #cccccc
}
</STYLE>
<META content="MSHTML 6.00.2900.2912" name=GENERATOR><BR>
<TABLE cellSpacing=0 cellPadding=0 width=400 border=0>
<TBODY>
<TR>
<TD vAlign=bottom align=left width=15 height=0 rowSpan=3><BR></TD>
<TD vAlign=top align=left width=0 colSpan=2 height=78>
<P class=style4>Milo van der Linden <BR><A
href="skype:milovanderlinden?add">skype: milovanderlinden</A><BR><A
href="mailto:mlinden@zeelandnet.nl">mlinden@zeelandnet.nl</A><BR><A
href="mailto:milovanderlinden@gmail.com">milovanderlinden@gmail.com</A><BR><A
href="mailto:milo@3dsite.nl">milo@3dsite.nl</A><BR><A
href="http://www.3dsite.nl">http://www.3dsite.nl</A><BR></P></TD>
<TD vAlign=top align=left width=15 height=0 rowSpan=3> </TD>
<TD vAlign=top width=300>
<P class=style5><SPAN lang=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.</SPAN>
<SPAN lang=EN>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.</SPAN></P></TD></TR></TBODY></TABLE></DIV>
<P>
<HR>
<P></P>_______________________________________________<BR>Cartoweb-users
mailing
list<BR>Cartoweb-users@lists.maptools.org<BR>http://lists.maptools.org/mailman/listinfo/cartoweb-users<BR></BLOCKQUOTE></BODY></HTML>