Hi Valerio,

you cant do that directly in the location plugin, but it is quite easy to extend that plugin to do what you want.

basically, you create a new plugin, lets call it MyProjectLocation

the template would look like this:


<?php
/**
* @package CorePlugins
* @version $Id: ClientMyProjectLocation.php,v 1.8 2005/02/23 11:52:43 Exp $
*/

class ClientMyProjectLocation extends ClientLocation {

   public function replacePlugin() {
       return 'location';
   }

// here redefine the function you need, most probably drawShortcuts() /** * Draws shortcuts form * @return string */ protected function drawShortcuts() { $this->smarty = new Smarty_Plugin($this->getCartoclient(), $this); $shortcutValues = array(-1); $shortcutLabels = array(''); $shortcuts = $this->shortcuts; if (!is_array($shortcuts)) $shortcuts = array(); /* do what you want with the array containing the shortcuts, list spliting, sorting, etc.... below is the original function code, allowing to treat the shortcuts values and labels */ foreach ($shortcuts as $key => $shortcut) { $shortcutValues[] = $key; $shortcutLabels[] = I18n::gt($shortcut->label); } /* now let say you cuted your shortcuts in 3 arrays (hence 3 for values and 3 for labels), you assign them to your template vis smarty */ /* below the original code */ $this->smarty->assign(array('shortcut_values' => $shortcutValues, 'shortcut_labels' => $shortcutLabels)); /* you would have to do something like this */ $this->smarty->assign(array('shortcut_values_1' => $shortcutValues_1, 'shortcut_labels_1' => $shortcutLabels_1, 'shortcut_values_2' => $shortcutValues_2, 'shortcut_labels_2' => $shortcutLabels_2, 'shortcut_values_3' => $shortcutValues_3, 'shortcut_labels_3' => $shortcutLabels_3)); return $this->smarty->fetch('shortcuts.tpl'); } /* you will also have to redefine the function handleShortcuts, because only one input (select) can have one id, so you need to tell the plugin to treat the value returned by these inputs too */ protected function handleShortcuts($request, $useDoit = true, $check = false) { if (isset($this->getHttpValue($request, 'shortcut_id')) { $shortcut_id = isset($this->getHttpValue($request, 'shortcut_id'); } else if (isset($this->getHttpValue($request, 'shortcut_id1')){ $shortcut_id = isset($this->getHttpValue($request, 'shortcut_id1'); } else if (isset($this->getHttpValue($request, 'shortcut_id2')){ $shortcut_id = isset($this->getHttpValue($request, ut_id2'); } else if (isset($this->getHttpValue($request, 'shortcut_id3')){ $shortcut_id = isset($this->getHttpValue($request, 'shortcut_id3'); } $shortcutDoit = $this->getHttpValue($request, 'shortcut_doit'); if (is_null($shortcut_id) || ($shortcutDoit != '1' && $useDoit)) { return NULL; } if ($check) { if (!$this->checkInt($shortcut_id, 'shortcut_id')) return NULL; if (!array_key_exists($shortcut_id, $this->shortcuts)) { $this->cartoclient->addMessage('Shortcut ID not found'); return NULL; } } $bboxRequest = new BboxLocationRequest(); $bboxRequest->bbox = $this->shortcuts[$request['shortcut_id']]->bbox; $locationRequest = new LocationRequest(); $locationRequest->locationType = LocationRequest::LOC_REQ_BBOX; $locationRequest->bboxLocationRequest = $bboxRequest; return $locationRequest; }}?>

and in your shortcuts.tpl simply put the smarty variable $shortcut_values_1
$shortcut_labels_1 $shortcut_values_2 $shortcut_labels_2 $shortcut_values_3
$shortcut_labels_3 as needed

<select name="shortcut_id1" id="shortcut_id1"
onchange="javascript:document.carto_form.shortcut_doit.value=1;FormItemSelected();">
{html_options values=$shortcut_values_1 output=$shortcut_labels_1}
</select>
<select name="shortcut_id2" id="shortcut_id2"
onchange="javascript:document.carto_form.shortcut_doit.value=1;FormItemSelected();">
{html_options values=$shortcut_values_2 output=$shortcut_labels_2}
</select>
<select name="shortcut_id3" id="shortcut_id3"
onchange="javascript:document.carto_form.shortcut_doit.value=1;FormItemSelected();">
{html_options values=$shortcut_values_3 output=$shortcut_labels_3}
</select>

Finally, dont forget tp load your new plugin. In the file client_conf/client.ini add it to the loadPlugins list

That should cover most of it.

All references are there:
http://www.cartoweb.org/doc_head/docbook/xhtml/dev.newplugin.html#dev.newplugin.adapting.extending

Regards,

Oliver Christen
Camptocamp SA

Hi,
is it possible to split shortcuts in two or more combo boxes (i.e. tows shortcuts and lakes shortcuts)? Do I have to modify php files or can I configure this in location.ini or similar?


Thanks

Valerio
_______________________________________________
Cartoweb-users mailing list
[email protected]
http://lists.maptools.org/mailman/listinfo/cartoweb-users


_______________________________________________
Cartoweb-users mailing list
[email protected]
http://lists.maptools.org/mailman/listinfo/cartoweb-users

Reply via email to