I'm trying to write a plugin that lives in the admin interface, that reads external data (a cinema program), parses it, and creates entries based on this (movie info and screening times).
While doing so I build a log of the additions/updates made, that I want to return to the template (the plugin page from where I trigger the update) and display the changes listed in a table. But I have trouble reading anything out with craft.request.getPost()
from the template.
The log, basically an array of custom models (log items), seems to be fine while still in the controller. I try to pass this array via craft()->urlManager->setRouteVariables()
, but at the template, it seems the only variables it finds are the action
and redirect
parameters from the original form.
The code in the controller looks like this:
$log = craft()->updateProgram_program->update();
craft()->urlManager->setRouteVariables(array(
'log' => $log
));
And then I try to read the log
variable in my template like this:
{% set log = craft.request.getPost('log') %}
Whatever I do, it seems to always be NULL
. I've also tried to set a simple text string as the value, in case it's not possible to post an array like this, but it's still NULL
when it comes to the template. It seems the log
parameter is simply not found in the POST
request at all.
Is there anything obvious I'm doing wrong?
I've scratched my head all day over this, so any tips are extremely welcome!