9 posts by 2 authors in: Forums > CMS Builder
Last Post: November 25   (RSS)

Hi Jerry,

What's happening here is that form submission details don't get passed along when you click a link (e.g. "?pdf=1") so the end result is the empty form. This is no different than if you visited the "?pdf=1" URL without submitting the form. A method you can use to test what will get rendered by createPDF_fromOutput('inline') is to simply comment out that function and then follow the same process - if the result in-browser isn't what you're expecting, then that helps narrow down where the issue is coming from.

There are a number of ways to address this - I'll give you a brief outline of my top two:

  1. If these form results are being saved to the DB, it should be possible to get the ID/num of the record being created, and then pass that along through the URL. (E.g. "?pdf=1&num=X"). Then, when the page gets loaded, check if "num" is being supplied by the URL and if so, retrieve the record and populate the necessary values on the page.
  2. Add all of the expected form values to the URL (e.g. "?pdf=1&name=X&email=Y..."). If your page is simply pulling the data from $_REQUEST this may simply work as-is, though that'll depend on exactly what's happening in your code. You'll also want to watch out that this doesn't save duplicate records, so pay attention to what condition triggers the save.

Hopefully this gets you on the right track - let me know if you have any questions!

Thanks,

Daniel
PHP Programmer
interactivetools.com

By gkornbluth - November 16 - edited: November 16

Hi Daniel,

I've managed to get createPDF working again and have posted what I found to be the issues on the other thread https://www.interactivetools.com/forum/forum-posts.php?82122 .

I'm still somewhat lost regarding this issue of generating a PDF of search results and have attached the search form viewer code.

BTW, when I comment out the line you suggested, I get the same result in the browser as if the form was not submitted.

I'm hoping that you can offer a few concrete code suggestions based on the attached viewer.

If this proves to be more complex then can be handled on the forum, I'd be happy to use one of your paid options for a solution.

You can see the on line results of the existing code at http://jkwebdesigns.com/eg/pdftest.php

Thanks,

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!

Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Attachments:

pdftest.php 32K

Hi Jerry,

I had misinterpreted a bit of your original post (I thought this was saving a record, rather than a search page) and had only provided you with half of the solution. Because you want to create a PDF of the search results, you need to simulate the form being submitted at the same time as the PDF generation. Clicking the link with "?pdf=1" clears all of the search values, as well as the "save" value that tells the page to show the search results.

One fairly minimal solution I can think of is instead of using a "convert this page to PDF" link, you could add a checkbox to the form with the name "pdf" and value "1" labelled something like "View search results as a PDF" so that the user can choose to receive a PDF of the results when they submit the form rather than clicking a link afterwards.

Another simple - but more tedious - solution is essentially #2 from my previous post, except you need to add "save=1" to the URL in addition to the relevant form values. A simple working example is http://jkwebdesigns.com/eg/pdftest.php?pdf=1&save=1&genre_keyword[]=1. The two main tasks you'd have are 1) building the URL string based on the submitted form values, and 2) updating the code to account for when both $_REQUEST['pdf'] and $_REQUEST['save'] are on; e.g. removing the "convert this page to PDF" link.

Let me know if you have any questions about the above, or, if you think you'll need some direct help, feel free to send us an estimate request: https://www.interactivetools.com/estimate/

Thanks!

Daniel
PHP Programmer
interactivetools.com

Hey Daniel,

Thanks for this. I'll give both a try and see where that gets me.

You're the BEST!

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!

Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Daniel,

Again a well earned vote of THANKS!

I implemented the first idea and it works perfectly for my needs.

Appreciate you folks having our backs, all the time.

Best,

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!

Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By gkornbluth - November 23 - edited: November 23

Hi Daniel,

I finally think I’ve figured out the intermittent problem I'm having with createPDF and the ‘content not found’ error.

The page I’m trying to convert to a PDF is index.php.

If I request a PDF with the URL as http://www.my_site.com/eg/ the request ends up as http://www.my_site.com/eg/? which throws the ‘content not found’ error.

If I specifically use the URL http://www.my_site.com/eg/index.php and then request the PDF, createPDF works every time.

I could create a new page with a different file name, but I’m betting that there’s a more elegant approach.

Any ideas?

Thanks,

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!

Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Hi Jerry,

Most often the "?" in the URL bar is due to a form set up like this:

<form action="?" method="post">

You should be able to correct your issue by changing the "?" to "index.php" like this:

<form action="index.php" method="post">

The only real drawback here is if you ever change the filename or want to copy the form to another page you'll need to update it, whereas the "?" is more portable.

Let me know if that helps!

Thanks,

Daniel
PHP Programmer
interactivetools.com

Thanks, Daniel, 

I was going to try that, but is seemed too simple...

Guess I should have given it a go before reaching out.

Thanks again,

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!

Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php