I would like to start off by saying this module is awesome! However there is an issue I have been trying to work on to make this module even better. Currently there is no great way for a non-techy person to download these PDF's since you have to use a long URL with submission ID's so I decided to make it simpler. A buddy of mine helped write the PHP ( www.d2burke.com ).

Here's what we did. When you create a webform the administrator can go look at the results that have been submitted which show up in a list. We made it so that the administrator can view the submission and at the top get a link to download that specific submission. No having to enter the long URL and it dynamically feeds in the Submission ID. There may be a better way to do this, but this is what worked for us.

1. Create a block for the download button.

This is the first step which will give you the download button on each of the submission pages. Make sure the PHP input format is enabled in the modules admin panel. Paste in the code below and be sure to change the link to your URL.

<?php
$url = $_SERVER['HTTP_HOST'];                            //gets the path

if(strpos($url, 'submission/'))                                //determine whether or not there is a submission id
{
    //$path = parse_url($url, PHP_URL_PATH);            //parse the path
    $position = strpos($url, 'submission/');            //find the postion to start looking for the id
    $position+=11;                                                   
    
    $sid = substr($url, $position);                        //get & set the id to a vaiable
}
else
    echo 'No submission id found'
?>

<a href="http://www.yoursite.com/fillpdf&fid=879&webform[nid]=569&webform[sid]=<?= $sid ?>">Download PDF</a>         //plug the id into a variable

Then restrict this download block to only be on the submission pages for example. node/(nodeID)/submission/*

This code pulls in the submission ID from the current URL and allows you to download the PDF of the current submission you are on.

I hope this can help someone. Feel free to make changes maybe there is an easier way.

Shane

Comments

ThaiGringo’s picture

Well the link didn't work for me as written. But, I played with the PHP a bit and came up with the following:

function curPageURL() {
 $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 }
 return $pageURL;
}

$url = curPageURL();                            //gets the path

if(strpos($url, 'submission/'))                                //determine whether or not there is a submission id
{
    //$path = parse_url($url, PHP_URL_PATH);            //parse the path
    $position = strpos($url, 'submission/');            //find the position to start looking for the id
    $position+=11;                                                  
   
    $sid = substr($url, $position);                        //get & set the id to a variable
    echo '<a href="http://www.website.com/fillpdf&fid=71&webform[nid]=1630&webform[sid]=';
    echo $sid;
    echo '">Download PDF</a>';
}
else
{
    echo 'No submission id found';

}

This does work for me.

I'm sure it is NOT optimal code. So, any hints to optimize it would be appreciated!

wizonesolutions’s picture

Version: 6.x-1.11 » 6.x-1.x-dev
Component: Code » User interface
Status: Needs review » Needs work

Just noticed your other code referencing this. So the idea here is to provide a block that provides a download link?

I think we're getting somewhere, but I'm still not quite sure that this use case is something many people have. I'd like to get input from other users if any of you are watching this issue. There are definitely ways to improve the user-facing side of things, but if we do it in-module it has to have a reasonable amount of utility for people in general. Otherwise, it can just remain as something people can do case-by-case.

wizonesolutions’s picture

Assigned: jsheffers » Unassigned

Unassigning also.

wizonesolutions’s picture

Status: Needs work » Fixed

No input ever came, so just closing...this has to be handled in the custom code sphere. I suppose a block might be an idea...but I want to hold off on any imposed UI elements like that unless there's good reason and keep the module pretty focused on generating PDFs. Handbook pages on how to achieve custom needs with the module are very welcome!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.