It’s worth noting that the method MUST start with “process_”. Here’s the CP code that does the checking:
// only methods beginning with 'process_' are allowed to be called via this method
if (($name = $this->input->get_post('accessory')) === FALSE
OR ($method = $this->input->get_post('method')) === FALSE
OR strncmp($method, 'process_', 8) != 0)
{
return $this->index();
}Not sure why “OR strncmp($method, ‘process_’, 8) != 0)” needs to be checked considering a method_exists conditional is further down the routine.
Just a quick one that I’d like to follow up regarding the get_safe_refresh()
I’m calling it as part of the process_xxx function to get a URL and then redirect to it - however, I’m noticing on some pages (such as on the ‘snippets’ page), it’s returning a 404 Page error when trying to redirect.
Do I need to pass the output of the $this->EE->cp->get_safe_refresh() into the process_xxx function instead?
Finally, with using the refresh - I don’t seem to be able to get alerts/confirmations using the notify() functionality. How would you recommend executing the process_xx function, redirecting the user back to the page (with the updated information from the process) and display the confirmation message in the header onload.
Hope this makes sense.
Cheers,
C.
Does anybody have any clues to how you would execute a PHP script within the EE/CI framework (so the methods/variables are available) by an action on the front-end such as clicking a link?
I’ve read about doing this if the link is from within the CP (as covered so far in this thread) but I’ve not found anything about executing a module script/method by front-end interaction.
Thanks.
I’ve written an accessory that lets you select different entries and ajax-posts the entry_id to a process_ function in my accessory PHP.
It looked to work great at first, I generated a link that looked like this:
<a href="http://.BASE.AMP.C=addons_accessories.AMP.M=process_request.AMP.accessory=cp_mpleads.AMP.method=process_quiz_dataid=base_path">Base Path</a>';Clicking it brings up my process_quiz_data method, outputting “Entry_ID:” in an empty page. But when I try to reach it using ajax POST(or GET for that matter), it generates the HTML of a normal page. It doesn’t output my method. I’ve no idea really whats the matter. My Javascript looks like this:
$.post($('a#base_path').attr('href'),{
entry_id: _id
}, function(data){
alert(data);
}, 'html');I was hoping for an output along the lines of “Entry_ID: 1” or similar… This is what my process_quiz_data method looks like:
[code]function process_quiz_data() {
exit('ENTRY_ID: '. $this->EE->input->post("entry_id"));
}[/code]
Any ideas of where I’ve gone wrong?
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.