Get Smarty

Donate

Donate Bitcoin Bitcoin
Paypal

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Sites Using Smarty

Largest classified with thousands of ads at Shoppok

Buy cheap eyeglasses from Cheapglasses123.com and save up to 80%.

Buy wedding dresses on SiteSteer.com - Best Online Wedding Dress Store

Buy prescription glasses from www.australiaglasses.com and save.

Cheap Glasses Now On Sale at GlassesPeople.com. Starts At $7.95.

Where to buy discount wedding dresses and cheap smart dresses free shipping - Weddingdresstrend.com

Find Wedding Dresses Online at Canada from Ca-dresses.com

{include_php}

IMPORTANT NOTICE

{include_php} is deprecated from Smarty, use registered plugins to properly insulate presentation from the application code. As of Smarty 3.1 the {include_php} tags are only available from SmartyBC.

Attribute Name Type Required Default Description
file string Yes n/a The name of the php file to include as absolute path
once boolean No TRUE whether or not to include the php file more than once if included multiple times
assign string No n/a The name of the variable that the output of include_php will be assigned to

Option Flags:

Name Description
nocache Disables caching of inluded PHP script

{include_php} tags are used to include a php script in your template. The path of the attribute file can be either absolute, or relative to $trusted_dir. If security is enabled, then the script must be located in the $trusted_dir path of the securty policy. See the Security section for details.

By default, php files are only included once even if called multiple times in the template. You can specify that it should be included every time with the once attribute. Setting once to FALSE will include the php script each time it is included in the template.

You can optionally pass the assign attribute, which will specify a template variable name that the output of {include_php} will be assigned to instead of displayed.

The smarty object is available as $_smarty_tpl->smarty within the PHP script that you include.

Example 7.55. function {include_php}

The load_nav.php file:


<?php

// load in variables from a mysql db and assign them to the template
require_once('database.class.php');
$db = new Db();
$db->query('select url, name from navigation order by name');
$this->assign('navigation', $db->getRows());

?>

  

where the template is:


{* absolute path, or relative to $trusted_dir *}
{include_php file='/path/to/load_nav.php'}
{include_php '/path/to/load_nav.php'}             {* short-hand *}

{foreach item='nav' from=$navigation}
  <a href="{$nav.url}">{$nav.name}</a><br />
{/foreach}

  

See also {include}, $trusted_dir, {php}, {capture}, template resources and componentized templates

Comments
No comments for this page.
Post a Comment
All comments are moderated. Support questions are ignored, use the forums instead.
Author:
Email: (not shown)
What is 10 plus 10? (Are you human?)

Sponsors [info]

UK Web Hosting @webhost.uk.net
Best Web Hosting @rshosting.com
Web Hosting UK @webhostinguk.com
Unlimited Web Hosting @infrenion.com
App Entwicklung @morphodo.com
Buy from China @dhgate.com
First Click Internet Marketing @fcinternetmarketing.com