Developer forum

Forum » Templates » Map filter
Giuseppina Giunta
Reply

I have this map with about 900 users in a group (Sedi):

http://www.escolapios.net/es-ES/Qu%C3%A9-hacemos/Donde-Estamos.aspx

Is it possible to automatically filter the location list by the field 'Department' instead of Group Id, and how can I show it in my map?

Thank you very much.

Giuseppina


Replies

 
Mikkel Ricky
Reply

Currently, you cannot use Department in the Maps template, but I've just added the missing tag in our development branch.

You can filter the list of locations on anything, but automatic filtering, i.e. creating the filter buttons (see Maps-filter.html), only works with groups. If you want to filter on other values, you have to manually build your filter buttons. Therefore it may be worth considering adding the user in the Sedi group to additional groups matching the departments – even though it will require some manual work (or tricks in the database).

Best regards,
Mikkel

 

 
Giuseppina Giunta
Reply

Hi Mikkel,

thank you for your reply. I have implemented departments as groups

http://scolopi.net.dynamicweb-cms.com/Default.aspx?ID=481&Purge=True

but this website has four languages so can I translate groups name?
Thank you.
Giuseppina

 
Mikkel Ricky
Reply

You cannot translate group names using built-in functionality, but you can add a piece of JavaScript to translate group names using @Translate tags in your template:

<script>(function() {
     var i, element,
     translation = {
         'Accoglienza/Alloggio': '<!--@Translate(Accoglienza_Alloggio, "Accoglienza/Alloggio")-->',
         'Aspirantato': '<!--@Translate(Aspirantato, "Aspirantato")-->',
         // ... more group names
     },
     elements = document.querySelectorAll('button[data-group-id], li[data-group-id] .group');
     for (i = 0; element = elements[i]; i++) {
         var text = element.innerHTML.replace(/^\s+/, '').replace(/\s+$/, '');
         if (translation[text]) {
             element.innerHTML = translation[text];
         }
     }
}())</script>

It's a bit of a hack, but it's the best we can do.

 
Giuseppina Giunta
Reply

Hi, I have tried it but it doesn't work.

(e.g. english version)

http://scolopi.net.dynamicweb-cms.com/Default.aspx?ID=789&Purge=True

I have inserted in the translation.xml file this code:

    <key name="Accoglienza/Alloggio">
    <translation culture="es-ES"><![CDATA[Acogida - alojamiento]]></translation>
    <translation culture="it-IT"><![CDATA[Accoglienza/Alloggio]]></translation>
    <translation culture="en-US"><![CDATA[Accomodation]]></translation>
    <translation culture="fr-FR"><![CDATA[Accueil - logement]]></translation>
  </key>
  <key name="Aspirantato">
    <translation culture="es-ES"><![CDATA[Aspirantado]]></translation>
    <translation culture="it-IT"><![CDATA[Aspirantato]]></translation>
    <translation culture="en-US"><![CDATA[Aspirancy]]></translation>
    <translation culture="fr-FR"><![CDATA[Juvénat]]></translation>
  </key>

and your script in the maps.html code.
I don't know where is the error.

An easier solution could be a direct link to the group ID? But I should know the right code to implement it.

Thank you for your attention.

Giuseppina

 
Mikkel Ricky
Reply

The script must be the very last thing in your Maps template. Otherwise it will not be able to find the labels that must be translated.

 

 

 

 
Giuseppina Giunta
Reply

resolved!

Thank you.

 

 

 

You must be logged in to post in the forum