Including PHP in templates doesn't seem to work?

This is an archive of the phpBB 2.0.x support forum. Support for phpBB2 has now ended.
Forum rules
Following phpBB2's EoL, this forum is now archived for reference purposes only.
Please see the following announcement for more information: viewtopic.php?f=14&t=1385785
Locked
Been Told
Registered User
Posts: 90
Joined: Sat May 07, 2005 11:26 pm

Including PHP in templates doesn't seem to work?

Post by Been Told »

I have tried to include a piece of PHP in a .tpl file and it just doesn't work...

I went along according to the following article:
http://area51.phpbb.com/docs/coding-gui ... templating
And when I put:

Code: Select all

<!-- PHP -->
echo "hello!";
<!-- ENDPHP -->
into a .tpl file, it is displayed as:
[quote]
echo "hello!";
[/quote]

What am I doing wrong?

I tried using <?php and ?> and the effect is the same.[/code]
User avatar
jwunderly
Registered User
Posts: 5740
Joined: Sun Mar 30, 2003 2:18 pm
Location: Easton, PA (in the groove)

Re: Including PHP in templates doesn't seem to work?

Post by jwunderly »

Been Told wrote: I have tried to include a piece of PHP in a .tpl file and it just doesn't work...


It won't, as the templating engine doesn't know how to process php code.

You can either install the extreme styles mod or assign the php "output" to a variable in the appropriate php file and then reference the variable in the tpl file
John (A cranky old man. "Looking for an echo ...")
using any control-panel install/update is like shooting yourself in the foot. It won't kill you, but you're really going to hobble around until it heals.
Using the wrong tools (Front Page, DreamWeaver) gives the same results
Do not PM me for Support!
Been Told
Registered User
Posts: 90
Joined: Sat May 07, 2005 11:26 pm

Re: Including PHP in templates doesn't seem to work?

Post by Been Told »

jwunderly wrote:
Been Told wrote:I have tried to include a piece of PHP in a .tpl file and it just doesn't work...


It won't, as the templating engine doesn't know how to process php code.

You can either install the extreme styles mod or assign the php "output" to a variable in the appropriate php file and then reference the variable in the tpl file

Thanks for the info.
I wonder why that isn't mentioned in the above guide? :( Do you happen to know where I can get an up to date version of that mod by the way?
User avatar
jwunderly
Registered User
Posts: 5740
Joined: Sun Mar 30, 2003 2:18 pm
Location: Easton, PA (in the groove)

Post by jwunderly »

John (A cranky old man. "Looking for an echo ...")
using any control-panel install/update is like shooting yourself in the foot. It won't kill you, but you're really going to hobble around until it heals.
Using the wrong tools (Front Page, DreamWeaver) gives the same results
Do not PM me for Support!
Been Told
Registered User
Posts: 90
Joined: Sat May 07, 2005 11:26 pm

Post by Been Told »

Thanks very very much for this. :)
Locked

Return to “2.0.x Support Forum”