Block/Section (in trad. sense) function needed?

From: Date: Thu, 02 May 2002 18:11:42 +0000
Subject: Block/Section (in trad. sense) function needed?
Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-76@lists.php.net to get a copy of this message
Hi, I posted this to the Smarty-General list firstly, in the switch discussion, but I don't think it's actually sutedto that list. At 11:20 AM 4/29/02 +0200, Bertrand DUNOGIER wrote:
and a switch / case is not harder to understand than a if / elseif / else is it ? :)
But for your kind of example a switch may still be overkill. What we want is the good old PHPLib (or is it IT[X]?) kind of section/block: <!-- Template --> {block name="LoggedIn"} You are logged into our site. Fancy that! {/block} {block name="LoggedOut"} Can you find the link to login. I think not... {/block} /* PHP Code */ $smarty->default_block_status = 'visible'; if (isset($_SESSION['AUTH'])) {
        $smarty->hide_block('LoggedOut');
} else {
        $smarty->hide_block('LoggedIn');
} Or of course you could have all blocks hidden by default, and then use $smarty->show_block() to make the right ones visible. The advantage with this construct is that it puts the logic firmly where it should be: back in your PHP code. I'm not suggesting that blocks should be repeatable like in PHPLib as {section} does that, but I do think that simple blocks like this would be a very good idea. Peter. -- Maple Design - quality web design and programming http://www.mapledesign.co.uk

« previous php.smarty.dev (#76) next »