Page 1 of 1

Missing dynamic content when Printing to PDF

Posted: Fri Jan 28, 2011 7:43 pm
by rvaneerd
Hi,

I created a UDT extracting parts of my calender table to be displayed in a simple table.
One of my users had some use for this.
Next I got the idea to offer people a simple feature to create a printable version (ie, a year-calendar) for this in PDF format.
I managed to enable the "Print to PDF" feature, but as soon as I press the link, a PDF is created, but it only contains the "fixed" data and not the dynamic data.
Anyone any idea, as all the data is present on the page.

Regards,
Rob.

ps. at this moment, I'm still using CMSMS 1.6.7 :-[

Re: Missing dynamic content when Printing to PDF

Posted: Fri Jan 28, 2011 8:05 pm
by rvaneerd
Hi,

Just found out that the same behaviour is noticed when just preparing the print-output.
Therefore it's not PDF-related.

If you want to see what's going on, here's the page (currently still hidden from the menu): http://www.rosmare.nl/trainingschema-overzicht

Regards,
Rob

Re: Missing dynamic content when Printing to PDF

Posted: Sat Jan 29, 2011 11:01 pm
by Dr.CSS
You may have to change the print to pdf template...

Re: Missing dynamic content when Printing to PDF

Posted: Sun Jan 30, 2011 10:09 am
by rvaneerd
Thanks for replying, but unfortunately neither of the options does ring a bell to me to get this sorted out.

Here's the page content that should be sent to the printer / PDF:

Code: Select all

{trainingschema_overzicht}

{cms_module module='printing' pdf='true'}
{trainingschema_overzicht} = the UDT that generates the content (see below).
Remember: It does show on the page before I press the "Print (to PDF)" link / button.
The above page is called from another CMSMS page with an HTML-form in it:

Code: Select all

<form action="?page=trainingschema-overzicht-list" method="post"> 
<table>
<tbody>
<tr>
<td>Startdatum (jjjj-mm-dd)</td>
<td><input name="SchemaOverzichtStart" type="text" /></td>
</tr>
<tr>
<td>Einddatum (jjjj-mm-dd)</td>
<td><input name="SchemaOverzichtEind" type="text" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="Genereer Overzicht" /></td>
</tr>
</tbody>
</table>
</form>
What I do see, of the resulting page, is that the only part being printed is the same as using a preview of the page whilst defining it: Only the "Fixed content" is shown, including the header of the generated table, but not the table generated using MySQL.
In fact everything from the below code is printed except for
[*]$report_start & $report_end in the first printed line after the <H3> line
[*]The four print statements taking care of printing the rows with data at the bottom.

Code: Select all

$report_start = '';
if (isset($_POST['SchemaOverzichtStart']))
{
    $report_start = $_POST['SchemaOverzichtStart'];
}
$report_end = '';
if (isset($_POST['SchemaOverzichtEind']))
{
    $report_end = $_POST['SchemaOverzichtEind'];
}

print "<__html>";
print " <HEAD>";
print "  <TITLE>Overzicht Trainingschema - O.S.V. Rosmare</TITLE>";
print " </head>";

print "</__body>";
print "<h3>OSV Rosmare: Overzicht Trainingschema</h3>";
print "Dit overzicht loopt van ".$report_start." tot ".$report_end;
print "<table border=1>";
print " <tr>";
print "  <th>Datum</th>";
print "  <th>Categorie</th>";
print " </tr>";

$sql = 'select distinct date_format( e.event_date_start , "%d/%m/%Y" ) as eventDate, e.event_title as title
                FROM cms_module_calendar_events e,
                         cms_module_calendar_categories c,
                         cms_module_calendar_events_to_categories ec
                WHERE e.event_date_start >= "'.$report_start.'"
                AND e.event_date_start <= "'.$report_end.'"
                AND c.category_name like \'Training%\'
                AND ec.category_id = c.category_id
                AND e.event_id = ec.event_id
                ORDER BY e.event_date_start';
   $result = mysql_query ($sql);
   print mysql_error();
   while ($r = mysql_fetch_array ($result)) {
     extract ($r);
     print ("<tr>");
     print ("<td>$eventDate</td>");
     print ("<td>$title</td>");
     print ("</tr>");
   }

print "</table>";
print "<__body>";
[glow]Trying to clarify things, I kind of come to the conclusion that the page appears to be called (again) without passing the data entered in the calling form, so the page is just regerated.[/glow]

Any further help would be greatly appreciated.

Regards,
Rob.

Re: Missing dynamic content when Printing to PDF

Posted: Sun Jan 30, 2011 10:11 am
by rvaneerd
Dr.CSS wrote:You may have to change the print to pdf template...
Hi,

As said in my previous reply, I don't think (anymore) that this is PDF related, but more the regeneration of the page, losing the data passed to it.

Regards,
Rob.

Re: Missing dynamic content when Printing to PDF [solved]

Posted: Thu Jun 30, 2011 1:19 am
by psy
Hi

I had a similar problem with the Print module failing to load dynamic content. In my case, part of the page was restricted to particular members of a FrontEndUser group. This section would not print.

Solution was to call the dynamic content within the actual Print template.:

Code: Select all

{if $page_alias eq 'mypage' and $ccuser->memberof('mygroup')}
{* call my dynamic content here *}
{else}

    {$content}
{/if}
psy