The right way is using filters. We need to create our own filter, a PHP function like this:
function url_add_get_var($url,$name,$value) {
$name = urlencode($name);
$value = urlencode($value);
// If there is no question mark in the URL ...
if (strpos($url,'?') === false) {
// Add the variable with a question mark
return "$url?$name=$value";
} else {
// If there is a question mark, add the variable with an ampersand
return "$url&$name=$value";
}
}
Now, we can use it in SPIP like this:
[(text|filter{var1,var2, ...})]
So, in this case:
[(#URL_ARTICLE|url_add_get_var{date,[(#ENV{date}|next_sunday)]})]
And the full code:
[(#ENV{date}|diffdays|<{40}|?{<a href="[(#URL_ARTICLE|url_add_get_var{date,[(#ENV{date}|next_sunday)]})]">Some text...</a>,''})]