Decoding URL in SPIP

205 Views Asked by At

I have a search form in SPIP which does a GET to /recherche

Now when I am typing something like cinéma the é is automatically being encoded to something like cin%25C3%25A9ma

In SPIP, if I do

<?php echo urldecode($_GET['recherche']; ?> 

It is being converted back to cinéma.

However, In SPIP, I would retrieve the value of recherche with something like this:

#ENV{recherche}

Is there someway to decode this variable. Any in-built function in SPIP?

4

There are 4 best solutions below

0
On

You can create your own filter, adding this function in your mes_fonctions.php file:

function filtre_urldecode($v) {
    return urldecode($v);
}

You then can use [(#ENV{recherche}|urldecode)] in your squelette.

0
On

There is no built-in function to decode an URL in SPIP. You have to use PHP's urldecode().

0
On

[(#ENV{recherche}|urldecode)] will do the job.

For reference, please see SPIP's filters: Adding your own filters

1
On

You don't have to create a new dedicated SPIP filter, since you can use PHP's urldecode as an SPIP filter. For example:

[(#ENV{recherche}|urldecode)]