Jump to content

smarty file include


hamza

Recommended Posts

 

this is how i am assigning file list.php contents in content variable to include in main template

        $arr = array(1000, 1001, 1002);
$smarty->assign('myArray', $arr);
$smarty->assign('pageTitle', 'Admin Control Panel - View Categories bhai jan');
$smarty->assign('content', 'list.php');//'list.php'

 

list.php file code is below

{* simple loop to display integers *}
{foreach from=$myArray item='foo'}
{$foo}
{/foreach}

 

 

 

including file dynamically using content variable

           <div id="main">
            
             {include_php file="$content"}
             
            </div>

 

Problem is that when file is include with contents of smarty

but not running it .

 

output is look like follow the link below

http://76.163.166.217/hamza/phpblog/phpblog/admin/catagory/

 

all paths are included perfectly

Link to comment
Share on other sites

{include_php} is deprecated, so you probably should avoid using it.  Not sure if that's what's causing the problem though.

 

Is the code from the third code block in a separate file thank the first two code blocks?

 

Do this, rename the list.php file to list.tpl.  On the third code block, change it to:

 

           <div id="main">
           
             {include_file="$content" myArray=$myArray}
             
            </div>

 

On the first code block, change 'list.php' to 'list.tpl.'

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.