[Cartoweb-users] search

Claire Chastagnol chastagnol.claire at wanadoo.fr
Mon Sep 8 05:42:10 EDT 2008


Hi everybody,


Since nobody answered, I try once more....

I would like to make possible to my cartoweb user to do different searches:
- search by road names.
- search by town names.
- ...

They are independant searches that use completely different tables of my database.

The searches work well when I put only one at a time in my project. But when I try to propose different searches, only one of them is working.


Here is what I did :

search.ini file:

dsn = pgsql://postgres:mypassword@localhost:5432/mydb

encodingContext = myEncoding 


config.route_fusion.provider.type = fulltextTable
config.route_fusion.provider.table = route_fusion
config.route_fusion.provider.id = gid
config.route_fusion.provider.columns = gid, data, reso01
config.route_fusion.provider.fulltextColumns = data
config.route_fusion.provider.sortColumn = gid
config.route_fusion.provider.sortDirection = asc
config.route_fusion.formatter.type = smarty
config.route_fusion.formatter.template = search_results


config.pr.provider.type = fulltextTable
config.pr.provider.table = pr
config.pr.provider.id = gid
config.pr.provider.columns = gid, route, prd
config.pr.provider.fulltextColumns = route
config.pr.provider.sortColumn = gid
config.pr.provider.sortDirection = asc
config.pr.formatter.type = smarty
config.pr.formatter.template = search_results


search.ajax.js file:

AjaxPlugins.Search = {
    
    handleResponse: function(pluginOutput) {
        

if (pluginOutput.htmlCode.route_fusion) {
    
    var targetElm = $('search_results_div');
    if (targetElm) {
        alert('element trouve!');
        targetElm.innerHTML = pluginOutput.htmlCode.route_fusion;
    } else {
        alert('element non trouve');
    }
} 

if (pluginOutput.htmlCode.pr) {
    
    var targetElm = $('search_results_div');
    if (targetElm) {
        alert('element trouve!');
        targetElm.innerHTML = pluginOutput.htmlCode.pr;
    } else {
        alert('element non trouve');
    }
}

else {
    alert('l element recherche n existe pas!');
}

    }  
};


/*
 * Search plugin's Actions
 */
 
AjaxPlugins.Search.Actions = {};

AjaxPlugins.Search.Actions.DoIt = {
    
    buildPostRequest: function(argObject) {
        return AjaxHandler.buildPostRequest();
    }
};

function order(column) {

    if (column != $('search_sort_column').value) {
        $('search_sort_column').value = column;
        $('search_sort_direction').value = 'asc';
    } else {
    if ($('search_sort_direction').value == 'asc') {
    $('search_sort_direction').value = 'desc';
    } else {
    $('search_sort_direction').value = 'asc';
    }
}
CartoWeb.trigger('Search.DoIt')
}




function recenter(id) {

    if ($('search_config').value == 'route_fusion'){
    
        $('id_recenter_ids').value = id;
        $('id_recenter_layer').value = $('search_config').value; 
    
    
    CartoWeb.trigger('Location.Recenter');
    }
    
    if ($('search_config').value == 'pr'){
    
        $('id_recenter_ids').value = id;
        $('id_recenter_layer').value = $('search_config').value; 
    
    
    CartoWeb.trigger('Location.Recenter');
    }
    
}

search.tpl file:

<div id="search_div">
    <fieldset><legend>{t}Recherche par nom de route{/t}</legend> <br/>
        <table width="100%">
            <tr>
                <td>
                    {t}Nom de la route : {/t}
                </td>
            <td>
                <input type="text" id="search_data"
                name="search_data" size ="13">
            </td>
        </tr>
    </table>
<p>
  <input type="submit" value="{t}Search{/t}" class="form_button"
  java-script="java-script: CartoWeb.trigger('Search.DoIt'); return false;"/>
           
  <input type="hidden" id="search_config" name="search_config" value="route_fusion"/>
  <input type="hidden" id="search_sort_column" name="search_sort_column" value="data"/>
  <input type="hidden" id="id_recenter_ids" name="id_recenter_ids"/>
  <input type="hidden" id="id_recenter_layer" name="id_recenter_layer"/>
  <input type="hidden" id="search_sort_direction" name="search_sort_direction" value="asc"/>
  <input type="hidden" id="search_number" name="search_number" />

 
    <div id="search_results_div"></div>
</p>
</fieldset>
</div>

<div id="search_div">
    <fieldset><legend>{t}Recherche par nom de route et pr{/t}</legend> <br/>
        <table width="100%">
            <tr>
                <td>
                    {t}Nom de la route : {/t}
                </td>
            <td>
                <input type="text" id="search_route"
                name="search_route" size ="13">
            </td>
        </tr>
    </table>
<p>
  <input type="submit" value="{t}Search{/t}" class="form_button"
  java-script="java-script: CartoWeb.trigger('Search.DoIt'); return false;"/>
           
  <input type="hidden" id="search_config" name="search_config" value="pr"/>
  <input type="hidden" id="search_sort_column" name="search_sort_column" value="route"/>
  <input type="hidden" id="id_recenter_ids" name="id_recenter_ids"/>
  <input type="hidden" id="id_recenter_layer" name="id_recenter_layer"/>
  <input type="hidden" id="search_sort_direction" name="search_sort_direction" value="asc"/>
  <input type="hidden" id="search_number" name="search_number" />

 
    <div id="search_results_div"></div>
</p>
</fieldset>

</div>

Anyone got an idea?

Many thanks.
Claire
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/cartoweb-users/attachments/20080908/6886e967/attachment-0001.html


More information about the Cartoweb-users mailing list