[pmwiki-devel] Passing information via the URL

Randy Brown randy at brownragfilms.com
Fri May 28 02:50:52 CDT 2010


I'm trying to pass information from page to page via parameters the URL and links that read that information, but it doesn't always work as I'd expect. 

For example, in the URL I have: ?n=mypage?s=mystring

In mypage's markup I have (using the httpvariables recipe): [[{$FullName}?s={$?s}|{$?s}]]

Notice how the s parameter in the URL is used as part of the URL in the link - I'm thus passing the information. This works fine if mystring is "plaintext", but fails if I have text such as "{=$Title}".

I suspect characters such as "{", "=", and "}" break the link. In an attempt to get around this, I created a directive to return a url-safe value, getting the value myself from the url parameter:

Markup('urlval', 'fulltext',
  '/\\(:urlval (.*?):\\)/e',
  "urlval('$1')");   
function urlval($key)
{
   $val = $_GET[$key];  
   $val = str_replace("{", '%7B', $val);
   $val = str_replace("}", '%7D', $val);
   return PUE(str_replace("=", '%3D', $val));
}

Then I changed the markup to [[{$FullName}?s=(:urlsafe s:)|{$?s}]]

But it still fails! I'm not sure why. 

What's puzzling is that if my function echoes the text that the directive is about to return, and I copy that echoed text directly into the markup, replacing the directive, the markup works.

Any suggestions on how to make this work?

Randy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.pmichaud.com/pipermail/pmwiki-devel/attachments/20100528/305c537b/attachment.html>


More information about the pmwiki-devel mailing list