1 kenton Oct 03, 2011 15:33
3 kenton Oct 06, 2011 10:45
Not sure I follow how that works :(
For now I have simply added the following to the plugin's constructor:
# check for _POST'ed value and do a redirect
$this->cb_name = 'cat_url';
$cat_url = param($this->cb_name, 'string');
if (isset($cat_url) && !empty($cat_url)) header_redirect($cat_url);
It appears to work and has the advantage of keeping the code within the plugin.
I should add that this needs only to work on blogs that contain the plugin (ie the cat_url is not only sent from such a blog/page but is itself an url to a blog/page containing the plugin)
4 sam2kb Oct 06, 2011 11:22
How do you display/post the form?
5 kenton Oct 06, 2011 12:36
Simple hard code output inside the plugin SkinTag()
The <form ... is output along with the <select ... <options
This was simpler than digging around to find any pre-defined (unclearly documented) function in the core.
The form contains a dropdown list of categories that are made available based on certain conditions.
It just seemed easier that way, keeping it in the new plugin.
But always welcome any suggestions if there is a more universal way of doing something ... as long as it does what is required of it.
6 sam2kb Oct 06, 2011 20:33
Simple hard code output inside the plugin SkinTag()
That's the right way :) Then just replace your form "action" URL with the one I posted above, and add two methods "GetHtsrvMethods" and "htsrv_whatever" to your plugin.
Never try to grab from input on plugin init, this is a huge overhead!
Once you setup your form to post data to /htsrv/call_plugin.php file you'll be able to grab submitted values with "htsrv_whatever". Dynamic action URL is generated by "$this->get_htsrv_url('whatever')"
7 kenton Oct 06, 2011 23:14
I don't see how there is any significant overhead in the constructor it is only called once on any client request and pulling the POSTed value using the param method is not going to be much different from any other solution - if it is then I could simply get the raw POSTed value and drop ot in a private class var and use that.
Doing it the way I have done it doesn't even require the overhead of loading the $Form class or any of the htsrv_whatever methods. As I said really simple and probably not PC
Still god to know there is an alternate way of doing things and when I have more time I will delve into htsrv_whatever and see what it does.
At the moment I don't understand it.
You need to post your form to /htsrv/call_plugin.php
Example: