• Welcome to AcornDomains.co.uk, a friendly community for UK domain investors, developers and anyone interested in domain names.

    Whether you're looking to buy or sell domains, learn more about the UK domain market, get feedback on your names, or simply chat with other domainers, you're in the right place. AcornDomains has been bringing together people from across the UK domain industry for many years, from complete beginners to experienced investors.

    Have a look around, join the discussions and, if you haven't already, create a free account and introduce yourself.

PHP include in a Smarty Template

Status
Not open for further replies.

AdminAdmin is verified member.

Administrator
Acorn Staff
Acorn Moderator
Developer
Server Admin
Nominet Registrar
Joined
Jun 14, 2004
Posts
11,191
Reaction score
1,059
Hi,

Does anyone know how to include a PHP file inside a Smarty template?

1, I create the PHP file, it works fine
2, Empty TPL file except for {include_php file="path and filename of PHP file"}

3, main page
Code:
<?
session_start();
 //includes
 require("includes/globals.php");
    //assign smarty variables
    $smarty->assign("page_title","[I]title[/I]");
    $smarty->assign("page_content","[I]TPL file with PHP include[/I]");
    $smarty->display("template.tpl");
?>

The page appears with the correct template but the PHP page content does not appear, instead I get the error:

Warning: Smarty error: pathandfilename.php is not readable in /home/name/public_html/smarty/libs/Smarty.class.php on line 1095

Any ideas anyone?

Thanks

Admin
 
sure you are using the correct file path?

your include line should look like this:

{include_php file=$page_content}
 
Status
Not open for further replies.
Top Bottom