View Full Version : Insert php code?
pipc01
07-23-2007, 01:08 AM
Hi mentors,
I would like to add 4 very short lines of php anywhere to show up on every page of my template, top or bottom, it matters not.
I have tried to add the raw php even to a php file, but unlike "normal" websites, this template does not finish in a closing php tag.
I am guessing I need a piece of code, to allow the php code, in the same way html is used.
Any ideas please?
Thank you
woostar
07-23-2007, 01:13 AM
I think (think) you can use {php} put your code here {/php} in your .tpl file
pipc01
07-23-2007, 02:21 AM
Unless I put it in the wrong place, it did not work, thanks for thee suggestion tho
Dave Baker
07-23-2007, 06:55 AM
Hello pipc01,
Did you use the same syntax:
{php}
include("/path/to/file.php");
{/php}
Also you can use this code in your *.tpl files:
{include_php file="/path/to/file.php"}
pipc01
07-24-2007, 04:27 AM
Hi Dave,
I have tried to add it in the header, no joy. I have tried to add it in the index no joy. I just need to add 2 files, /add.php and /this.php I have tried both your xamples. Neither worked for me, or I am too thick to follow basic instructions. Any idea where I should add them for them to show near either the header or footer?
Many thanks, Mark
Dave Baker
07-24-2007, 11:47 AM
Mark,
If you send me your ftp credentials and save your files in the root of your directory, I will try to help you. :)
seppppel
09-03-2007, 04:55 AM
hello
this works fine on my "detail-page":
{php}
include("/path/to/file.php");
{/php}
now my question. is this:
{php}
include("/path/to/file.php?parameter=$listing.id");
{/php} possible? I need the listing id to call my include file.
thanks, seppppel
Dave Baker
09-03-2007, 05:21 AM
Hello seppppel,
Yes, this is possible, but with slightly another syntax. Try something like this:
{php}
$yourVar=$this->get_template_vars('listing');
include("/path/to/file.php?parameter=".$yourVar['id']);
{/php}
seppppel
09-03-2007, 05:35 AM
:good: thanks Dave :good:
Dave Baker
09-03-2007, 06:01 AM
You're welcome seppppel :)
antex
12-19-2007, 07:21 AM
Hello Dave,
Still question:
I have variable,
For example:
{php}
$p = 7;
{/php}
As it to transfer in .tpl file?
{$p}
Thanks
Dave Baker
12-20-2007, 03:44 AM
Hello antex,
Try something like this:
{php}
global $gDirSmarty;
$gDirSmarty->assign('p', 7);
{/php}
vBulletin® v3.7.0, Copyright ©2000-2008, Jelsoft Enterprises Ltd.