tags:

views:

116

answers:

1

I was wondering. How do you guys deal with scenario of website where you have login and log out states at the top. So if someone is logged in, you say "Hello Scott". If someone's not logged in, it says "Log In".

I am using force compile = false. And using

(!$smarty->is_cached('index.tpl',$template_cache_id)) {
 do something
}

What do you guys use to keep some sections not cache and others cached for such a common scenario? My site is photoidentify.com

Thanks!

+2  A: 

I have defined a block function that excludes small blocks of the templates from cache.

function smarty_block_dynamic($param, $content, $smarty) {
    return $content;
}

$smarty->register_block("dynamic", "smarty_block_dynamic", false);

Thus, anything in the template surrounded by {dynamic}{/dynamic} will not be cached. This allows for the output of, for example, session based data such as the logged in user name et cetera.

clops
Thanks so much!! Was waiting for a long time for answer!
Scott