Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2015-10-06 09:04:28

alivato
Member
Registered: 2011-03-31
Posts: 151

Add php code

I need to insert after <body> This php code (default form)

<?php echo rating_bar('id21',''); ?>

If you insert a so

<txp:php> echo rating_bar('id21',''); </txp:php>

Error

Last edited by alivato (2015-10-06 09:10:09)

Offline

#2 2015-10-06 09:11:06

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: Add php code

Hi alivato

do you have php enabled in Preferences>Advanced>Allow PHP in pages?

Also I am not sure what the php is pointing to. Are you trying to make use of an external php script?


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#3 2015-10-06 09:20:42

alivato
Member
Registered: 2011-03-31
Posts: 151

Re: Add php code

yes

…external php script?

how?

<txp:php>include 'path/file.php';</txp:php>

Last edited by alivato (2015-10-06 09:23:38)

Offline

#4 2015-10-06 09:33:35

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: Add php code

could you please post your article template for us to see?


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#5 2015-10-06 09:42:48

alivato
Member
Registered: 2011-03-31
Posts: 151

Re: Add php code

default form

<txp:if_article_list>
<article>
<div class="art_name"><txp:title />
<txp:php>require_once 'http://site.com/rating/tipic.php';</txp:php>
</div>
<txp:body />
<txp:excerpt />
</article>
<txp:else />
...
Fatal error: require_once() [function.require]: Failed opening required 'http://site.com/rating/topic.php' (include_path='.:/opt/alt/php53/usr/share/pear:/opt/alt/php53/usr/share/php') in /home/a13131/public_html/site.com/textpattern/publish/taghandlers.php(3836) : eval()'d code on line 1

If this code

<txp:php> echo rating_bar('id21',''); </txp:php>
Fatal error: Call to undefined function rating_bar() in /home/a13131/public_html/site.com/textpattern/publish/taghandlers.php(3836) : eval()'d code on line 1

Last edited by alivato (2015-10-06 10:05:47)

Offline

#6 2015-10-06 11:40:42

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Add php code

<txp:php>require_once 'http://site.com/rating/topic.php';</txp:php>

Assuming that this PHP code is hosted at your own website, don’t use an URL, but the local file path to that PHP file, something like home/a13131/public_html/site.com/rating/topic.php

Offline

Board footer

Powered by FluxBB