How to add php code in template files

Get help with installation and running phpBB 3.0.x here. Please do not post bug reports, feature requests, or MOD-related questions here.
Scam Warning
Forum rules
END OF SUPPORT: 1 January 2017 (announcement)
Locked
bbhit
Registered User
Posts: 34
Joined: Wed Dec 01, 2010 12:35 pm

How to add php code in template files

Post by bbhit » Thu Dec 09, 2010 4:27 pm

I want to add php code in the template files,
sample add in overall_footer.html,each visit will exc the php code

how,thanks

Update
I had add a code in overall_footer.html

Code: Select all

<!-- INCLUDE ../../../1.txt -->
then refresh the style,it had a file "tpl_prosilver-se_.........1.txt.php" in the root/cache
so,each visit will include this tpl_prosilver-se_.........1.txt.php,but I need to each visit will include the 1.txt,1.txt will change times

Pit$Bull
Former Team Member
Posts: 23099
Joined: Sat Dec 02, 2006 4:08 pm
Name: Can't Remember

Re: How to add php code in template files

Post by Pit$Bull » Thu Dec 09, 2010 4:41 pm

ACP->main page->security settings
Security settings - Mozilla Firefox_2010-12-09_10-39-36.png
Security settings - Mozilla Firefox_2010-12-09_10-39-36.png (4.96 KiB) Viewed 15862 times

User avatar
stevemaury
Support Team Member
Support Team Member
Posts: 50425
Joined: Thu Nov 02, 2006 12:21 am
Location: The U.P.
Name: Steve
Contact:

Re: How to add php code in template files

Post by stevemaury » Thu Dec 09, 2010 4:42 pm

Two ways. Withing the html file, like this:

Code: Select all

<!-- PHP -->
echo "hello!";
<!-- ENDPHP -->
Or from an external file, like this:

Code: Select all

<!-- INCLUDEPHP somefile.php -->
You must also enable the use of hph in template files in the ACP, Security settings.
For REALLY good and VERY inexpensive hosting CLICK HERE

I can stop all your spam. I can upgrade or update your Board. PM or email me. (Paid support)

bbhit
Registered User
Posts: 34
Joined: Wed Dec 01, 2010 12:35 pm

Re: How to add php code in template files

Post by bbhit » Fri Dec 10, 2010 2:23 am

Thanks Pit$Bull and stevemaury

Thanks

bbhit
Registered User
Posts: 34
Joined: Wed Dec 01, 2010 12:35 pm

Re: How to add php code in template files

Post by bbhit » Fri Dec 10, 2010 11:28 am

Update question

can use

Code: Select all

<!-- IF SCRIPT_NAME == "viewtopic" -->
and

Code: Select all

<!-- ELSEIF SCRIPT_NAME == "viewforum" -->
to know this script is topic or forum,what about the index.php,how to know this script is index?

thanks

bbhit
Registered User
Posts: 34
Joined: Wed Dec 01, 2010 12:35 pm

Re: How to add php code in template files

Post by bbhit » Fri Dec 10, 2010 6:14 pm

some body help?

User avatar
darcie
Community Team Member
Community Team Member
Posts: 5541
Joined: Thu Jul 27, 2006 9:52 am
Location: Davis, California
Name: Darcie Griffin
Contact:

Re: How to add php code in template files

Post by darcie » Fri Dec 10, 2010 6:22 pm

You basically use the name of the file without the php extension. See http://www.phpbb.com/community/viewtopi ... #p12878139 for a whole list of them.
phpBB on Facebook | Site Rules | Former Community Team leader

Locked

Return to “[3.0.x] Support Forum”