Fork me on GitHub

ModDev: How to create a bare pnRender page for printing  Bottom

  • I have a form that I want users to be able to print, so I'd like it without all the PN wrappings.

    How do I do this in PN.750 using pnRender and templates? Here's what I have so far.

    I have a template: /modules/mymodule/templates/mytemplate.htm.

    I created printapp.php which gets all the info and calls pnRender->fetch(xxx) to draw the form.

    My module uses pnredirect to get to printapp.php?mid=$mid (where mid is the ID of the thing I'm trying to print) when the user clicks on "print the form".

    If I put printapp.php in root and set xxx to "/modules/mymodule/templates/mytemplate.htm" it does nothing. I'm guessing fetch expects the template to be in a certain template directory under the current directory, but there's no documentation I can find on the pnRender class that explains how fetch works (fetch under Smarty is something totally different).

    If I put printapp.php in my module directory and change the includes to include the pnAPI.php, etc from ../.., then I get:

    Code

    Call to undefined function: adonewconnection() in /usr/local/psa/home/vhosts/theboarder.net/httpdocs/includes/pnAPI.php on line 432


    I'm assuming (although haven't tried it) that if I change it to a module function, that it will just get wrapped automatically like the rest of it. I was basing my solution on what print.php does for news, although that's not currently a templated solution so of very limited use.

    I could change it away from a templated solution, but that seems like a bit of a cop out, because it's all templated so far.

    So, basically, how do I go "calling" a page to display a template without the PN wrappings from within a module?
  • It's always gratifying to work it out yourself.

    I did it by calling another function and passing the id as a session variable. Instead of returning the result of calling pnRender->fetch(mytemplate.htm) I assigned it to a variable called form, did an echo $form and exit.

    That did the trick. Did lose stylesheets and stuff, but no big worry in this case.

    I also looked into using pnRender->display rather than fetch. The solution arose before I tried that, but that could also be a pointer for people who have similar problems. In the end I delved into the /includes/pnRender.class.php for my "documentation".
  • THe plan, for .8 is a "print" view theme. AutoTheme has one, and I thint CRS has one too.

    --
    Home Page | Find on Facebook | Follow on Twitter

This list is based on users active over the last 60 minutes.