Add the Action PHP Use Include Pages[1] to the Freeway page where you
want your script to work. Give your page the .php filename extension,
or configure your server to parse all html files as if they were PHP.
The Action will write a require() statement to insert the code into
your page at the very top of the HTML file – before the DOCTYPE or
any other code is written, so you can use headers without fear. And it
will manage the upload of this code to your server, and maintain a
live link to the code so that any updates in your original trigger a
new upload to the server.
Make sure that you write your code so that it sets up variables with
values, rather than printing out results right then and there. For
example:
//not this
print 'Foo bar baz';
//or
echo $_POST['first_name'];
but rather this
$message = 'Foo bar baz';
//or
$first_name = $_POST['first_name'];
Then, further down in the visible part of your Freeway page, where you
want something to appear, you can do this inside a Markup Item or an
instance of the Crowbar Action:
<?= $message ?>
//or, if your server doesn't do "short tags"
<?php echo $message; ?>
You place that precisely where you want it to appear in the page, and
you can add a styled space on either side of the markup container to
give the resulting text some style.
Freeway’s markup elements are a pain in the posterior to do code
editing of any length beyond a few words, so using the Action lets you
write the bulk of your code in a proper programmer’s editor, and to
take advantage of debugging and syntax highlighting to make that part
of the job easier. It also encourages you to think modularly, to
package your code together into functions that you call or variables
that you print back, rather than a mish-mosh of intermingled logic and
presentation. You can leave your PHP script open in your editor, and
every time you update (and save) your script and then upload your page
to the server in Freeway, the new code will be used in your page. It’s
the best of all worlds.
Walter
- PHP Use Include Pages - ActionsForge
On Jan 23, 2011, at 2:01 PM, WildCottage wrote:
Hi Mike B and DeltaDave
Thanks for the replies. Certainly in the case of a form the action
route sounds easier, but my question was really a general one.
Is it possible to take the results of a PHP script to populate a
table created in Freeway? [for instance]
At this stage I’m just learning; results of forms would perhaps be
better done through an “Action”. I’ll keep reading the books and see
how I go.
Any other info on integration:
Quote
- To get the information from a PHP variable such as $name into a
Freeway page you could simply write <?php echo $name; ?> But the
script would need to be integrated with that page in some way or the
variable been sent to that Freeway page for it to have and show it’s
value.
Unquote
How would this be done?
Wild Cottage
freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options
freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options