How to Include a PHP File in TPL

Premade website templates created from the Smarty web page generating engine have the .tpl file extension. The template file (TPL) holds the general layout and graphics of the website design that other pages of the website pulls from to formulate the structure of all of the pages. PHP is a scripting language used to create dynamic websites. You can add PHP coding to the TPL file to include other files in the website's template. Many people do this to incorporate scrolling banners or other dynamic components into the overall design of the website.

1 Open the template file in a web-authoring program or in a text editor. Click the mouse in the part of the code you want to include the PHP file.

2 Type in the code using the PHP "include" function within the Smarty PHP tags that will include the PHP file inside of the TPL file.

"{php}

include("folder/filename.php");

{/php}"
Your Ad Here

Change the "folder/filename.php" to the filename and location of the PHP file that you want to include. Save the file.

3 Load the file and the PHP file you want to include into the correct folder locations on your web server. The code won't work and you will receive an error if the PHP file isn't in the folder you specified in the code.



Read more: How to Include a PHP File in TPL

Comments