Actions based on url parameters
October 2, 2007Just the other day I finished rewriting the whole comments section in the administration panel of Pixelpost. I’ve been fed up by the numerous options, buttons and all the other stuff I’ve banned from my mind. So I opted for a WordPress like approach instead and it turned out quite nicely.
With the new Defensio addon I was able to use the new features I implemented but soon I got stuck. Whenever I clicked a button or a hyperlink I returned to a different page then the page I was on. Pretty frustrating and certainly not user-friendly. I dug in a little deeper and found the offending code.
The “a href” code of the links (there were multiple forms in Pixelpost) were hardcoded like this:
index.php?view=comments&page=$newpage
In the old situation there was only one comments view, but now we have subviews and the possibilities of special views created by addons. Some change was in order and I found it quickly:
$_SERVER['PHP_SELF']?$_SERVER['QUERY_STRING']&page=$newpage
This way the url is aware of the settings it had. So subviews are retained as well as possible other options by the addons. This approach is 1) far better and 2) more flexible then the old approach of hardcoding the url.
As for Defensio, it has truly amazed me thus far.















