1

I have a custom module that's a multi-page form that collects one value from a user for each page of the form (3 pages, 3 total values collected). On the final page of the form (the recommendations page) it displays recommended resources from our database that match the user's selections. Because we need to put all 'timely events' first, followed by 'quick study' events, and finally 'deep dive' events the recommendations page uses 3 SQL queries to output the data to the screen.

All that works fine. However, now we'd like to add some way to allow the user to EXPORT the recommendations they see on the screen to a CSV file (or some other type) with an 'export' link. That's why I'm here asking you guys...does anyone know a great way to make this happen?

Here's the recommendations page code:

// function to return results from DB based on what user entered
function pathfindertool_recommendations_page() {

    //first test if variables passed from Pathfinder tool
    if (isset($_SESSION['role']) AND isset($_SESSION['level']) AND 
    isset($_SESSION['topic'])) {
        // set variables
        $role = $_SESSION['role'];
        $level = $_SESSION['level'];
        $topic = $_SESSION['topic'];

        // gather session variables and give them string values
        if ($role == 0) {
            $role = "Grant Writer";
        }
        elseif ($role == 1) {
            $role = "Nonprofit Administrator";
        }
        elseif ($role == 2) {
            $role = "Nonprofit Founder";
        }
        else {
            $role = "Consultant";
        }

        if ($level == 0) {
            $level = "Novice";
        }
        elseif ($level == 1) {
            $level = "Experienced";
        }
        else {
            $level = "Professional";
        }

        if ($topic == 0) {
            $topic = "Grants Research";
        }
        elseif ($topic == 1) {
            $topic = "Grant Writing";
        }
        elseif ($topic == 2) {
            $topic = "Grant Management";
        }
        else {
            $topic = "Strategic Planning";
        }

        // set $output var
        $output ='';

        // print and email link styling
        $output .= '<div class="print-link-rec"><span class="print_html"><a 
    class="print-page" rel="nofollow" title="Display a printer-friendly 
    version of this page." href="/print/pathfinder/recommendations"><img 
    class="print-icon print-icon-margin" width="16px" height="16px" 
    title="Printer-friendly version" alt="Printer-friendly version" 
    src="/sites/all/modules/contrib/print/icons/print_icon.png" 
    typeof="foaf:Image">Printer-friendly version</a></span></div>';

        // progress bar
        $output .= '<div class="progress-bar" id="progress-bar"><span 
    id="step-one">Primary Role</span><span id="arrow1"> > </span><span 
    id="step-two">Experience Level</span><span id="arrow2"> > </span><span 
    id="step-three">Topics of Interest</span><span id="arrow3"> > </span> 
    <span id="recommendations" style="background-color: 
    #003863;">Recommendations</span></div>';

        // remind user what they selected in form
        // but first, set pro and grants research to the preferred edits
        if ($level == "Professional") {
            $level2 = "Advanced";
        } else {
            $level2 = $level;
        }
        if ($topic == "Grants Research") {
            $topic2 = "Grant Research";
        } else {
            $topic2 = $topic;
        }
        $output .= '<div class="selected">You selected <em>' . $role . 
    '</em>, <em>' . $level2 . '</em>, and <em>' . $topic2 . '</em>.</div>';

        // sql for Timely Events
        $result = db_query("SELECT n.title, n.nid, n.status, n.type, 
    fdfty.field_type_value, fdfi.entity_id, fdfi.field_icon_tid, 
    fdfti.entity_id, fdfti.field_taxonomy_icon_fid, fm.uri, fm.fid, 
    ua.source, ua.alias, el.field_experience_level_value, fdb.body_value,
    fdfr.field_role_value, fdft.field_topics_value, 
    fdfed.field_event_dates_value, fdfed.field_event_dates_value2, 
    fdfl.field_location_value, fdfl.entity_id, 
    fdfo.field_organization_value, fdfo.entity_id FROM {node} AS n LEFT JOIN 
    {field_data_field_type} AS fdfty ON n.nid=fdfty.entity_id LEFT JOIN 
    {field_data_field_icon} AS fdfi ON n.nid=fdfi.entity_id LEFT JOIN 
    {field_data_field_taxonomy_icon} AS fdfti ON 
    fdfi.field_icon_tid=fdfti.entity_id LEFT JOIN {file_managed} AS fm ON 
    fdfti.field_taxonomy_icon_fid=fm.fid LEFT JOIN {url_alias} AS ua ON 
    CONCAT('node/', nid)=source LEFT JOIN 
{field_data_field_experience_level} AS el ON n.nid=el.entity_id LEFT JOIN 
    {field_data_body} AS fdb ON n.nid=fdb.entity_id LEFT JOIN 
    {field_data_field_role} AS fdfr ON n.nid=fdfr.entity_id LEFT JOIN 
    {field_data_field_topics} AS fdft ON n.nid=fdft.entity_id LEFT JOIN 
    {field_data_field_event_dates} AS fdfed ON n.nid=fdfed.entity_id LEFT 
    JOIN {field_data_field_location} AS fdfl ON n.nid=fdfl.entity_id LEFT 
    JOIN {field_data_field_organization} AS fdfo ON n.nid=fdfo.entity_id 
    WHERE n.status=:status AND n.type=:resource AND 
    (fdfty.field_type_value=:webinar OR 
    fdfty.field_type_value=:workshoptraining OR 
    fdfty.field_type_value=:conference) AND 
    el.field_experience_level_value=:level AND fdfr.field_role_value=:role 
    AND fdft.field_topics_value=:topic AND ((fdfed.field_event_dates_value 
    IS NULL) OR (fdfed.field_event_dates_value >= CURRENT_DATE())) GROUP BY
     n.nid, n.title ORDER BY CASE WHEN fdfty.field_type_value='1' THEN 0 
    WHEN fdfty.field_type_value='2' THEN 1 WHEN fdfty.field_type_value = '3'
     THEN 2 END, fdfed.field_event_dates_value, n.title", array(':status' => 
    '1', ':resource' => 'resource', ':webinar' => '1', ':workshoptraining' 
    => '2', ':conference' => '3', ':level' => $level, ':role' => $role, 
    ':topic' => $topic));

        // count how many results returned
        $num_rows = $result->rowCount();
        $counter = $num_rows;

        // test if results
        if ($num_rows > 0) {

            // output header
            $output .= '<h2 class="recheader" id="timevents">Timely 
    Events</h2>';

            // return results to page
            while ($row = $result->fetchAssoc()) {

                // set variables
                $date1 = $row['field_event_dates_value'];
                $timestamp = strtotime($date1);
                $date2 = $row['field_event_dates_value2'];
                $timestamp2 = strtotime($date2);                
                $title = $row['title'];
                $nid = $row['nid'];
                $alias = $row['alias'];
                // set image to display correctly for category
                $icon = image_style_url('thumbnail', $row['uri']);
                // select price image
                $result2 = db_query("SELECT n.title, n.nid, fdfp.entity_id,
     fdfp.field_price_tid, fdfcm.entity_id, fdfcm.field_costs_money_fid, 
    fm2.fid, fm2.uri FROM {node} AS n LEFT JOIN {field_data_field_price} AS 
    fdfp ON n.nid=fdfp.entity_id LEFT JOIN {field_data_field_costs_money} AS 
    fdfcm ON fdfp.field_price_tid=fdfcm.entity_id LEFT JOIN {file_managed} 
    AS fm2 ON fdfcm.field_costs_money_fid=fm2.fid WHERE n.nid = :nid", 
    array(':nid' => $nid));
                while ($row2 = $result2->fetchAssoc()) {
                    if ($row2['uri'] == 'public://dollar-sign.png') {
                        $dollar = image_style_url('thumbnail', $row2['uri']);
                    } else {
                        $dollar = "";
                    }
                }
                $desc = $row['body_value'];
                $ftv = $row['field_type_value'];
                // set dates to display correctly and add other output to 
    make page styled
                if ($date1 != $date2) {
                    $output .= '<div class="recentry"><img src="' .$icon. '"
     id="icon" alt="Timely Event" title="Timely Event" />';
                        if ($dollar != "") { 
                            $output .= '<img src="' .$dollar. '" id="price" 
    alt="Costs Money" title="Costs Money" />'; 
                        } else { 
                            $output .= ""; 
                        } 
                    $location = $row['field_location_value'];
                    $organization = $row['field_organization_value'];
                    $output .= '<h2 class="rectitle"><a href="../' . $alias 
    . '">' . $title . '</a></h2><div class="recdates">' . date('l, F j, Y', 
    $timestamp) . ' to ' . date('l, F j, Y', $timestamp2) . '</div><div 
    class="recdesc">';
                    if (($location != NULL) && (($ftv == '2') || ($ftv == 
    '3'))) {
                        $output .= '<div class="location">' . $location . 
    '</div>';
                    }
                    if (($organization != NULL) && (($ftv == '1') || ($ftv 
    == '2') || ($ftv == '3'))) {
                        $output .= '<div class="org">' . $organization . 
    '</div>';
                    }
                    $output .= '<div class="description">' . $desc  . '</div>
    </div></div>';
                } elseif ($date1 == $date2) {
                    $output .= '<div class="recentry"><img src="' .$icon. '" 
    id="icon" alt="Timely Event" title="Timely Event" />';
                        if ($dollar != "") { 
                            $output .= '<img src="' .$dollar. '" id="price" 
    alt="Costs Money" title="Costs Money" />'; 
                        } else { 
                            $output .= ""; 
                        } 
                    $location = $row['field_location_value'];
                    $organization = $row['field_organization_value'];
                    $output .= '<h2 class="rectitle"><a href="../' . $alias
     . '">' . $title . '</a></h2><div class="recdates">' . date('l, F j, Y', 
    $timestamp) . '</div><div class="recdesc">';
                    if (($location != NULL) && (($ftv == '2') || ($ftv == 
    '3'))) {
                        $output .= '<div class="location">' . $location . 
    '</div>';
                    }
                    if (($organization != NULL) && (($ftv == '1') || ($ftv 
    == '2') || ($ftv == '3'))) {
                        $output .= '<div class="org">' . $organization . 
    '</div>';
                    }
                    $output .= '<div class="description">' . $desc  . '</div>
    </div></div>';
                } else {
                    $output .= '<div class="recentry"><img src="' .$icon. '" 
    id="icon" alt="Timely Event" title="Timely Event" />';
                    $output .= '/>';
                        if ($dollar != "") { 
                            $output .= '<img src="' .$dollar. '" id="price" 
    alt="Costs Money" title="Costs Money" />'; 
                        } else { 
                            $output .= ""; 
                        } 
                    $location = $row['field_location_value'];
                    $organization = $row['field_organization_value'];
                    $output .= '<h2 class="rectitle"><a href="../' . $alias 
    . '">' . $title . '</a></h2><div class="recdesc">';
                    if (($location != NULL) && (($ftv == '2') || ($ftv == 
    '3'))) {
                        $output .= '<div class="location">' . $location .
     '</div>';
                    }
                    if (($organization != NULL) && (($ftv == '1') || ($ftv 
    == '2') || ($ftv == '3'))) {
                        $output .= '<div class="org">' . $organization . 
    '</div>';
                    }
                    $output .= '<div class="description">' . $desc  . '</div>
    </div></div>';
                }
            }
        }

        // sql for Quick Study items
        $result = db_query("SELECT n.title, n.nid, n.status, n.type, 
    fdfty.field_type_value, fdfi.entity_id, fdfi.field_icon_tid, 
    fdfti.entity_id, fdfti.field_taxonomy_icon_fid, fm.uri, fm.fid, 
    ua.source, ua.alias, el.field_experience_level_value, fdb.body_value, 
    fdfr.field_role_value, fdft.field_topics_value, 
    fdfl.field_location_value, fdfl.entity_id, 
    fdfo.field_organization_value, fdfo.entity_id FROM {node} AS n LEFT JOIN
     {field_data_field_type} AS fdfty ON n.nid=fdfty.entity_id LEFT JOIN 
    {field_data_field_icon} AS fdfi ON n.nid=fdfi.entity_id LEFT JOIN 
    {field_data_field_taxonomy_icon} AS fdfti ON 
    fdfi.field_icon_tid=fdfti.entity_id LEFT JOIN {file_managed} AS fm ON 
    fdfti.field_taxonomy_icon_fid=fm.fid LEFT JOIN {url_alias} AS ua ON 
    CONCAT('node/', nid)=source LEFT JOIN 
    {field_data_field_experience_level} AS el ON n.nid=el.entity_id LEFT 
    JOIN {field_data_body} AS fdb ON n.nid=fdb.entity_id LEFT JOIN 
    {field_data_field_role} AS fdfr ON n.nid=fdfr.entity_id LEFT JOIN 
    {field_data_field_topics} AS fdft ON n.nid=fdft.entity_id LEFT JOIN 
    {field_data_field_location} AS fdfl ON n.nid=fdfl.entity_id LEFT JOIN 
    {field_data_field_organization} AS fdfo ON n.nid=fdfo.entity_id WHERE 
    n.status=:status AND n.type=:resource AND 
    (fdfty.field_type_value=:articlereport OR fdfty.field_type_value=:blog 
    OR fdfty.field_type_value=:recweborpodcast OR 
    fdfty.field_type_value=:newslettermagazine) AND 
    el.field_experience_level_value=:level AND fdfr.field_role_value=:role 
    AND fdft.field_topics_value=:topic GROUP BY n.nid, n.title ORDER BY CASE 
    WHEN fdfty.field_type_value='4' THEN 0 WHEN fdfty.field_type_value = '5' 
    THEN 1 WHEN fdfty.field_type_value = '6' THEN 2 WHEN 
    fdfty.field_type_value = '7' THEN 3 END, n.title", array(':status' => 
    '1', ':resource' => 'resource', ':articlereport' => '4', ':blog' => '5', 
    ':recweborpodcast'=> '6', ':newslettermagazine'=>'7', ':level' => 
    $level, ':role' => $role, ':topic' => $topic));

        // count how many results returned
        $num_rows = $result->rowCount();
        $counter .= $num_rows;

        if ($num_rows > 0) {
            $output .= '<h2 class="recheader" id="quickstudy">Quick 
    Study</h2>';

            //return results to page
            while ($row = $result->fetchAssoc()) {

                // set variables    
                $title = $row['title'];
                $nid = $row['nid'];
                $desc = $row['body_value'];
                $alias = $row['alias'];
                // set image to display correctly
                $icon = image_style_url('thumbnail', $row['uri']);
                $result2 = db_query("SELECT n.title, n.nid, fdfp.entity_id, 
    fdfp.field_price_tid, fdfcm.entity_id, fdfcm.field_costs_money_fid, 
    fm2.fid, fm2.uri FROM {node} AS n LEFT JOIN {field_data_field_price} AS
     fdfp ON n.nid=fdfp.entity_id LEFT JOIN {field_data_field_costs_money} 
    AS fdfcm ON fdfp.field_price_tid=fdfcm.entity_id LEFT JOIN 
    {file_managed} AS fm2 ON fdfcm.field_costs_money_fid=fm2.fid WHERE n.nid 
    = :nid", array(':nid' => $nid));
                while ($row2 = $result2->fetchAssoc()) {
                    if ($row2['uri'] == 'public://dollar-sign.png') {
                        $dollar = image_style_url('thumbnail', $row2['uri']);
                    } else {
                        $dollar = "";
                    }
                }
                    $ftv = $row['field_type_value'];
                    $output .= '<div class="recentry"><img src="' .$icon. '"
     id="icon" alt="Quick Study" title="Quick Study" />';
                    if ($dollar != "") { 
                        $output .= '<img src="' .$dollar. '" id="price" 
    alt="Costs Money" title="Costs Money" />'; 
                    } else { 
                        $output .= ""; 
                    } 
                    $organization = $row['field_organization_value'];
                    $output .= '<h2 class="rectitle"><a href="../' . $alias 
    . '">' . $title . '</a></h2><div class="recdesc">';
                    if (($organization != NULL) && ($ftv == '6')) {
                        $output .= '<div class="org">' . $organization . '</div>';
                    }
                    $output .= '<div class="description">' . $desc  . '</div>
    </div></div>';
                }
            }

        // sql for Deep Dive items
        $result = db_query("SELECT n.title, n.nid, n.status, n.type, 
    fdfty.field_type_value, fdfi.entity_id, fdfi.field_icon_tid, 
    fdfti.entity_id, fdfti.field_taxonomy_icon_fid, fm.uri, fm.fid, 
    ua.source, ua.alias, el.field_experience_level_value, fdb.body_value, 
    fdfr.field_role_value, fdft.field_topics_value, 
    fdfl.field_location_value, fdfl.entity_id, 
    fdfo.field_organization_value, fdfo.entity_id FROM {node} AS n LEFT JOIN
     {field_data_field_type} AS fdfty ON n.nid=fdfty.entity_id LEFT JOIN 
    {field_data_field_icon} AS fdfi ON n.nid=fdfi.entity_id LEFT JOIN 
    {field_data_field_taxonomy_icon} AS fdfti ON 
    fdfi.field_icon_tid=fdfti.entity_id LEFT JOIN {file_managed} AS fm ON 
    fdfti.field_taxonomy_icon_fid=fm.fid LEFT JOIN {url_alias} AS ua ON 
    CONCAT('node/', nid)=source LEFT JOIN 
    {field_data_field_experience_level} AS el ON n.nid=el.entity_id LEFT 
    JOIN {field_data_body} AS fdb ON n.nid=fdb.entity_id LEFT JOIN 
    {field_data_field_role} AS fdfr ON n.nid=fdfr.entity_id LEFT JOIN 
    {field_data_field_topics} AS fdft ON n.nid=fdft.entity_id LEFT JOIN 
    {field_data_field_location} AS fdfl ON n.nid=fdfl.entity_id LEFT JOIN 
    {field_data_field_organization} AS fdfo ON n.nid=fdfo.entity_id WHERE 
    n.status=:status AND n.type=:resource AND (fdfty.field_type_value=:tool 
    OR fdfty.field_type_value=:bookorworkbook OR 
    fdfty.field_type_value=:certificateordegreeprogram) AND 
    el.field_experience_level_value=:level AND fdfr.field_role_value=:role 
    AND fdft.field_topics_value=:topic GROUP BY n.nid, n.title ORDER BY CASE
     WHEN fdfty.field_type_value='8' THEN 0 WHEN fdfty.field_type_value = 
    '9' THEN 1 WHEN fdfty.field_type_value = '10' THEN 2 END, n.title", 
    array(':status' => '1', ':resource' => 'resource', ':tool' => '8', 
    ':bookorworkbook' => '9', ':certificateordegreeprogram'=>'10', ':level' 
    => $level, ':role' => $role, ':topic' => $topic));

        // count how many results returned
        $num_rows = $result->rowCount();
        $counter .= $num_rows;

        if ($num_rows > 0) {

            $output .= '<h2 class="recheader" id="deepdive">Deep Dive</h2>';

            //return results to page
            while ($row = $result->fetchAssoc()) {

                // set variables
                $title = $row['title'];
                $nid = $row['nid'];
                $desc = $row['body_value'];
                $alias = $row['alias'];
                // set image to display correctly
                $icon = image_style_url('thumbnail', $row['uri']);
                $result2 = db_query("SELECT n.title, n.nid, fdfp.entity_id,
 fdfp.field_price_tid, fdfcm.entity_id, fdfcm.field_costs_money_fid, 
fm2.fid, fm2.uri FROM {node} AS n LEFT JOIN {field_data_field_price} AS fdfp 
ON n.nid=fdfp.entity_id LEFT JOIN {field_data_field_costs_money} AS fdfcm ON 
fdfp.field_price_tid=fdfcm.entity_id LEFT JOIN {file_managed} AS fm2 ON 
fdfcm.field_costs_money_fid=fm2.fid WHERE n.nid = :nid", array(':nid' => 
$nid));
                while ($row2 = $result2->fetchAssoc()) {
                    if ($row2['uri'] == 'public://dollar-sign.png') {
                        $dollar = image_style_url('thumbnail', $row2['uri']);
                    } else {
                        $dollar = "";
                    }
                }
                    $ftv = $row['field_type_value'];
                    $output .= '<div class="recentry"><img src="' .$icon. '"
 id="icon" alt="Deep Dive" title="Deep Dive" />';
                    if ($dollar != "") { 
                        $output .= '<img src="' .$dollar. '" id="price" 
alt="Costs Money" title="Costs Money" />'; 
                    } else { 
                        $output .= ""; 
                    } 
                    $location = $row['field_location_value'];
                    $organization = $row['field_organization_value'];
                    $output .= '<h2 class="rectitle"><a href="../' . $alias 
. '">' . $title . '</a></h2><div class="recdesc">';
                    if (($location != NULL) && ($ftv == '98')) {
                        $output .= '<div class="location">' . $location . 
'</div>';
                    }
                    if (($organization != NULL) && ($ftv == '98')) {
                        $output .= '<div class="org">' . $organization .
 '</div>';
                    }
                    $output .= '<div class="description">' . $desc  . '</div>
</div></div>';
            }
        }

            if ($counter == "0") {
                // if no entries matched what user entered give them 
alternative text.
                $output .= '<div id="no-recs-returned"><p class="recdesc">'
 . "Sorry, your selections did not result in any recommendations at this 
time. " . '<a href=' . "/pathfinder" . '>' . "Go here to try again" . 
'</a></p></div>';
            }

        // return variable to display results
        return $output;

        // if user went directly to rec page without taking questionnaire
    } else {

        $output = "";

        // progress bar html/css styling
        $output .= '<div class="progress-bar" id="progress-bar"><span 
id="step-one">Primary Role</span><span id="arrow1"> > </span><span id="step-
two">Experience Level</span><span id="arrow2"> > </span><span id="step-
three">Topics of Interest</span><span id="arrow3"> > </span> <span 
id="recommendations" style="background-color: 
#003863;">Recommendations</span></div>';

        $output .= '<p class="recdesc">' . "You haven't yet taken the 
questionnaire; please " . '<a href="/pathfinder">' . "go here to get 
started" . '</a>.</p>';

        return $output;
    }

}
1

If it would be an option to create that "report" on your recommendations page using the Forena module, then it would be just a matter of specifying what kind of hyperlinks you want to make available for performing such "export". These hyperlinks correspond to various supported "formats", such as: CSV, PDF, XLS, XML, DOC, HTML ...

To get an idea of how that would look like, visit the demo site samples. Checkout the samples such as the Master detail with nested blocks. There is a link "PDF" (upper right), which in this case would "export" the results there in a PDF doc. Though it could as well (or "also") be a CSV, XLS, DOC, etc (if that is what the "report designer" would have selected as one of the allowed/enabled export formats).

For more details about Forena, 2 types of documentation are available:

  • Community documentation, which includes a child page Video demos and tutorials.
  • Documentation that comes with Forena, which you can access right after install and enable of the module. Checkout the demo site for an online example of the current:

    • Forena documentation - use the link 'Reporting documentation' or visit relative link /reports/help.
    • Forena samples - use the link 'Reporting samples' or visit relative link /reports/samples (these samples are fully functional, so make sure to experiment a bit with it, such as the drill downs available on the SVG Graph sample).

Access to reports (and export links):

  • Who can "Access" a specific report is a matter of granting access to the "data block" (= results of an SQL query). While access to those (export) links is a matter of being able to access the report (via its data block). So if "Anonymous" is allowed to access some data block, then those links on its report can be accessed also (and hence perform a save/export also). Those PDF links in the demo site samples are an illustration of that (since you visit that site anonymous).

  • Extra feature: yes or no showing a link for (eg) CSV or PDF export and (eg) not for XLS is something you can specify when designing / creating a report. Though that yes or no then applies to anybody.

Reports audience:

The "audience" of reports can be however you want it to be, which is typically implemented using what's called report "categories". As an illustration (based on various reports delivered out-of-the-box):

  • the Forena 'Sample' reports are a set of reports with a specific category (= 'Samples' also), for which Anonymous users are granted access also.
  • the Forena 'Drupal Admin' reports is another set, with some other category, and which can only be accessed by users with role "admin". So if somebody installs Forena in some Drupal site, and they have the "admin" role, then they get access to all sorts of Drupal admin related reports (like watchdog reports) in their "own" environment. Some of those reports are:

    • Active Users - A variation of D7's admin/people, including hyperlinks to the Logs for User report.
    • Logs for User - Most recent watchdog log entries for a user (specified as a report parameter).
    • Role Details - A table displaying all users for a Drupal role (specified as a report parameter), and the Drupal permissions granted to them, with for each user hyperlinks to either view or edit the user's profile.

Disclosure: I'm a (co-)maintainer of Forena,
I hope this does not violate the site's policy on self-promotion.

  • this looks interesting; I'll explore it more. Would this module allow an anonymous user to be able to save their own report and export it? That's what I want...a user customized report for anonymous users (based on their form responses). I'm a little worried this module is only for admins or admin-created reports for users (ie. no interaction involved with users). – Sage Jul 11 '15 at 0:32
  • it makes sense, thank you. I do have another follow up question however: will this module allow for user-created reports using parameters they set by selecting options in my form? (ie. can I plug php variables into parameters fields in forena reports so they read what the user selected in my custom module?) – Sage Jul 14 '15 at 19:13
  • Thank you for the update, looks like we're going in the right direction to get your question solved. I'm assuming that for that "using parms they set" it should be possible also. However I'd first want to better understand what you mean with those php variables. E.g. in which format are they available at that point, like did you save those parms by then in some Drupal table? If not how "are" they available? – Pierre.Vriens Jul 14 '15 at 19:25
  • Great, so the module is a multi-page form where users enter their selections. Once they've made them they submit the values which get send to a recommendations page (the code above). The values they selected are, right now being stored in session variables (see the beginning of the code above) ... there are only 3 variables. The SQL statements (later in the code above) then use those session variables to compare to the data in the DB to determine which records to display to the user (their 'recommendations'). So, the values being selected are being saved as sessions only. – Sage Jul 14 '15 at 19:31
  • I suppose so. So I create a report, setup the data block in a .sql file in a custom dir on my server (with the sql and params to call) and then call it from structure > reports? I tried this and followed the videos. I have my sql in sites/files/recs/test.sql and I setup my forena report (config > forena) so custom data block repo is set to the above path. I then created a new report in structure > forena reports and tried to create a new sql query to map to my sql file I setup but it can't seem to find it anywhere. I type in 're' in source and it only gives registry or reg_file. – Sage Jul 14 '15 at 22:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.