Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2013-02-05 11:28:03
- beechy
- Member
- Registered: 2006-03-02
- Posts: 92
php and textpattern 4.5.4
In a previous version of textpattern (4.2.0) I was using the following raw php in one of my textpattern page templates to output content from an external php application I had built:
<?php
include('/pathtofile/config.php');
include($txpcfg['txpath'].'/extra-config.php');
include(JOBS_ROOT.'/file.php');
$ja=new jobsAdmin();
$res=$ja->getLatestJob(true);
unset($ja);
?>
This code was working fine in textpattern (4.2.0)
I’ve just updated to the latest version of textpattern (4.5.4) and updated the above php code to use the <txp:php>……</txp:php> tags and allowed php in the textpattern preferences, I’m now seeing the following error and no textpattern forms below the above php code are being processed. I haven’t changed anything in the actual page template.
Tag error: <txp:output_form form="form_name" /> -> Textpattern Notice: Form not found: form_name while parsing form “None” on page “default”
Does the latest version of textpattern handle php differently from previous version, and if so how does it deal with objects?
THanks for your help.
Offline
#2 2013-02-05 12:26:56
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,315
Re: php and textpattern 4.5.4
If form_name and None are names you really used, I’d start changing these. If not, I withdraw in favor of the more knowledgeable ones ;)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: php and textpattern 4.5.4
Raw PHP tag support was deprecated years back. In 4.5.0, this deprecated optional setting and feature was removed. To run PHP, see php tags. E.g.
<txp:php>
include '/pathtofile/config.php';
include txpath .'/extra-config.php';
include JOBS_ROOT.'/file.php';
$ja = new jobsAdmin();
$res = $ja->getLatestJob(true);
</txp:php>
In the above I also changed the txpcfg global to automatically generated txpath
constant, and removed the unset()
. Each <txp:php>
block is evaluated in its own function context (scope), instead of in global namespace. This also means that the initialized variables do not carry over from one block to other unless lifted from one scope to other (by using global keyword for instance).
Offline
#4 2013-02-05 14:12:03
- beechy
- Member
- Registered: 2006-03-02
- Posts: 92
Re: php and textpattern 4.5.4
Hi Gocom,
Thanks for the reply.
I’ve tried your suggested code, and this seems to work but only if I have the php code placed at the very bottom of the textpattern page, if its not placed as the last thing on the page, it does display however all the html and textpattern forms below it are not being outputted when I view the page on the front end of the site and i’m seeing a load of error messages.
Any ideas?
Thanks again.
Last edited by beechy (2013-02-05 14:12:56)
Offline
Pages: 1