For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > August 2005 > resource - variable









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author resource - variable
michal.720

2005-08-15, 5:04 pm

Hello,
I have page content (string) in a variable {$page_content}. I can simply
"echo" this content by smarty like this

My content: {$page_content}

I need to process smarty tags in this string. The content (string) can
be saved into a file or database and then called by {include} plugin
like this

{include file="my-page-content.tpl"} and it will work.

But I need something like resource-from-variable. I created the most
simpliest piece of code which works.

Important code parts:

// resource
function var_get_template($tpl_name, &$tpl_source, &$smarty_obj)
{
$tpl_source = $tpl_name;
return TRUE;
}
....
....
$smarty->register_resource('var',
array(
$page,
'var_get_template',
'var_get_timestamp',
'var_get_secure',
'var_get_trusted'
)
);

And template

{include file="var:`$page_content`"}


Does anybody have any hints about this?

Thanks,
Michal
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com