I've installed Forena Reports. It's basically working, but I have some questions (see bottom of post to get right to it).
What I want to accomplish is the following
I want an anonymous user of the module page to be able to export their recommendations as a CSV file with a link like 'download now' or something.
Here's the staging environment for the tool I'm talking about, so you can see how it works: http://staging.grantstation-pathfinder.com/pathfinder.
So, as you can see, here's what I have so far
I have a custom module that's a multi-step form. The module prints out each page of the form. The user selects one option on each page (3 pages total) and on the final page submits the form. The module then redirects the user to a 'recommendations' page (page 4 - modulename/recommendations) where some custom SQL prints out to the page recommended resources for that user based on their selections in the form.
The values the users select are saved in session variables.
Here's how those variables get stored as sessions in the form itself. (This is the second page of the form, but they are all basically the same.)
function pathfindertool_first_form($form, $form_state) {
// .. some code, some other fields, directions, etc.
'#default_value' => isset($values['role']) ? $values['role'] : NULL,
'#options' => array(
t('Grant Writer'),
t('Nonprofit Administrator'),
t('Nonprofit Founder'),
t('Consultant'))
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Next'),
);
return $form;
}
/**
* Submit handler for the first form.
*
* @see pathfindertool_first_form() above
*/
function pathfindertool_first_form_submit($form, &$form_state) {
$values = $form_state['values'];
// Save values to the form storage, add the next step function callback
$form_state['rebuild'] = TRUE;
$form_state['storage']['role'] = $values['role'];
// submit code
}
On the recommendations page I call SQL and use the session variables to determine which recommendations to display to users.
Here's how I set the session variables and redirect the users to the recommendation's page.
$form_state['storage']['topic'] = $values['topic'];
// set session variables to be used on recommendations page
$_SESSION['role'] = $form_state['storage']['role'];
$_SESSION['level'] = $form_state['storage']['level'];
$_SESSION['topic'] = $form_state['storage']['topic'];
// when user clicks 'submit' redirect them to recommendations page
$form_state['redirect'] = 'pathfinder/recommendations';
I successfully installed and configured the Forena module, and it displays my tabular data from the SQL file I created with the parameters I manually set. The CSV download works too. That's all fine.
How do I ensure the Forena modules uses the session variables set by the user in the multi-page form (and not my predefined parameters)?