I'm using SPIP with files of my own that are included according to keywords. For example, adding the keyword inc-bla
to an article makes that the file .../squellettes/.../inc-bla.html
is included. In one of those files, I want to make a link to the current page with a GET variable added to the URL:
[(#ENV{date}|diffdays|<{40}|?{<a href="#URL_ARTICLE?date=[(#ENV{date}|next_sunday)]">Some text...</a>,''})]
Now the problem is that the question mark ?
is hard-coded, and sometimes the URL already has a question mark. So this code creates links like ...spip.php?article123?date=2014-03-30
, which should be ...spip.php?article123&date=2014-03-30
. I cannot hard-code an ampersand &
because not every link has a question mark in it already.
Is there a way to add a GET variable to a URL in SPIP?
The right way is using filters. We need to create our own filter, a PHP function like this:
Now, we can use it in SPIP like this:
So, in this case:
And the full code: