PHPRunner

All posts tagged PHPRunner

The task: in a PHPRunner event, launch a PDF in a new tab/window.    Really??  Something that I had expected to be super-trivial ended up taking me hours of googling stack overflow just to figure out how to approach this.   Let’s start with why it was a problem and then get to the very quick one-liner solution.  This is more a PHP tip, than a PHPRunner tip, but I needed it recently in a PHPRunner application so maybe you do to?

First of all, even though we use PHP for web page interactions, it’s very easy to forget that PHP is a server-side scripting language. Especially as we have PHP script events surrounding all our data interactions in PHPRunner – it “feels” like PHP code is executing on the client. But it’s not! All of which means that PHP cannot make the browser do anything directly.

If you were building a web page in HTML, there are plenty of ways to set a hyperlink and tie an event/listener to it so that your user can click the href and you can control how the link opens a new target.  But what I (and many others apparently) were chasing was how to have a PHPRunner Add page accept data, and in an after_record_added event, have a PHP process run and generate a PDF dynamically based on data just added, then once the server processing is complete, and the PDF is available on the server, have it automatically open the PDF for the user.  In a new window or tab.  We should note here that the latter part isn’t something you get to decide – the user’s browser decides whether it will default to open the ‘window’ either as a new tab or as a new window.  All you can do is open the window.  Which is quite acceptable.

Continue Reading

This topic is all about how you can put your PHP code into separate source files and use those functions in your event scripts in PHPRunner applications. When your applications start to get more complicated, a few things happen.

a) you start to get longer and more complicated event scripts, and in my personal opinion, once you are over a few dozen lines of PHP, you will probably do better structuring your scripts into functions.

b) you start to get script features you want to include in more than page or button, or even in more than one PHPRunner application – having your code in a separate PHP file makes this trivial and means you aren’t duplicating code. Continue Reading