View previous topic :: View next topic |
Author |
Message |
mzanier_XTC Smarty Regular
Joined: 04 May 2003 Posts: 38
|
Posted: Wed Sep 24, 2003 2:48 pm Post subject: assign + caching other files |
|
|
hi,
i got a small cms in my shopsystem, where you ca add txt/html/php etc files as "content" for display.
is there any way to assign the file "output" in php to smarty , like the fetch() for templates ?
or is there any way to include a non template file with smarty tags in the template ? ( {include} wont work).
regards+thx,
mario _________________ [quote]
http://www.xt-commerce.com |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Wed Sep 24, 2003 4:38 pm Post subject: |
|
|
mzanier_XTC, how do you do?
I think you want to look at PHP's output buffering.
Last edited by boots on Thu Sep 25, 2003 8:38 pm; edited 2 times in total |
|
Back to top |
|
mzanier_XTC Smarty Regular
Joined: 04 May 2003 Posts: 38
|
Posted: Thu Sep 25, 2003 11:50 am Post subject: |
|
|
re,
well, normaly ill used in my php file without tpls.
include(DIR_FS_CATALOG.'media/content/'.$shop_content_data['content_file']);
if i go for ob
Code: |
<?php
function callback($buffer) {
$smarty->assign('file',$buffer);
}
ob_start("callback");
include(DIR_FS_CATALOG.'media/content/'.$shop_content_data['content_file']);
ob_end_flush();
?>
|
does smarty cache the content of file also ?
regards,
mario _________________ [quote]
http://www.xt-commerce.com |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Thu Sep 25, 2003 12:21 pm Post subject: |
|
|
yes, it does. if caching is enabled the *output* of the template is cached.
the old value of $file will be re-displayed. |
|
Back to top |
|
mzanier_XTC Smarty Regular
Joined: 04 May 2003 Posts: 38
|
Posted: Thu Sep 25, 2003 2:27 pm Post subject: |
|
|
well i tried a bit with OB, the problem is, that i cant asign the output.
if ill use:
Code: |
<?php
function callback($buffer) {
$smarty->assign('file',$buffer);
}
ob_start("callback");
include(DIR_FS_CATALOG.'media/content/'.$shop_content_data['content_file']);
ob_end_flush();
?> |
ill get white screen, if ill use an echo $buffer; within the callack function, nothing getting displayed, only if ill use return $buffer; the file output is on screen, but displaced.
you got any hint how to fetch this into a var ? thats kinda asuming..
regards+thx,
mario _________________ [quote]
http://www.xt-commerce.com |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Thu Sep 25, 2003 2:42 pm Post subject: |
|
|
you have to say "global $smarty" in your callback-function.
or simply do:
[php:1:61c16a6537]ob_start();
do-the-include-foo
$smarty->assign('file', ob_get_contents());
ob_end_clean();
[/php:1:61c16a6537]
and omit your callback-function. |
|
Back to top |
|
mzanier_XTC Smarty Regular
Joined: 04 May 2003 Posts: 38
|
Posted: Thu Sep 25, 2003 3:07 pm Post subject: |
|
|
hm,,
now the file get fetched, but
ob_start();
if (strpos($shop_content_data['content_file'],'.txt')) echo '<pre>';
include(DIR_FS_CATALOG.'media/content/'.$shop_content_data['content_file']);
if (strpos($shop_content_data['content_file'],'.txt')) echo '</pre>';
$smarty->assign('file',ob_get_contents());
ob_end_flush();
->> ill get also the output of the include (like normal include) on my screen, + the output in the smarty variable. _________________ [quote]
http://www.xt-commerce.com |
|
Back to top |
|
mzanier_XTC Smarty Regular
Joined: 04 May 2003 Posts: 38
|
Posted: Thu Sep 25, 2003 3:11 pm Post subject: |
|
|
ob_end_clean();
working )
thx for help+happy we,
mario _________________ [quote]
http://www.xt-commerce.com |
|
Back to top |
|
|