Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

including a php file in smarty....

 
Post new topic   Reply to topic    Smarty Forum Index -> Smarty Development
View previous topic :: View next topic  
Author Message
major7
Smarty n00b


Joined: 24 Jul 2003
Posts: 4

PostPosted: Thu Jul 24, 2003 9:16 am    Post subject: including a php file in smarty.... Reply with quote

I intend to return a partial js-code into my template.
when I do it the way you see below, it doesn't work, since the include prints the code on top of the rest, not where it usually belongs

this is an extract from my primary php file:

Code:
$tpl->assign("HANDLE_ACTION_DOKU", include($DOCUMENT_ROOT."/doc/actions/handle_action_doku.php"));


in my template i assign it like this:

Code:
{$HANDLE_ACTION_DOKU}
{$RENDER_MENU_DOKU}


The handle_action_doku.php file is not smarty-based, if it were there wouldn't be any problems...

Does anyone have any idea?
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Thu Jul 24, 2003 10:08 am    Post subject: Reply with quote

you can use {include_php} see:
http://smarty.php.net/manual/en/language.function.include.php.php
(but be aware that you are inside a function and have to handle globals properly if you need them in your handle_action_doku.php)

or you can use output_buffering:
http://www.php.net/manual/en/ref.outcontrol.php

[php:1:68894f8baa]
ob_start();
include($DOCUMENT_ROOT."/doc/actions/handle_action_doku.php");
$tpl->assign("HANDLE_ACTION_DOKU", ob_get_contents());
ob_end_clean();
[/php:1:68894f8baa]

HTH
messju
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Smarty Development All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP