Welcome Guest, Not a member yet? Register   Sign In
Using <!--- ---> instead of <?php ?> in view files
#14

[eluser]Dready[/eluser]
Why isn't that possible ?

Code:
Hello {username}
{if_blue}You you have blue eyes{/if_blue}
{if_red}You you have red eyes{/if_red}
{else}You have sunglasses{/else}

And in your controller :
Code:
$tpl = array('username'=>$this->user->name, 'if_blue' => array(),'if_red'=>array(),'else'=>array());
if ( $this->user->eyes->color == 'blue' ) {
  $tpl['if_blue'][] = array();
} elseif ( $this->user->too_much_smoke ) {
  $tpl['if_red'][] = array();
} else  {
  $tpl['else'][] = array();
}
$this->parser->parse('myview',$tpl);

It's really a matter of taste, I like my template files without any PHP code, so web designers can work on design, and php developer (including me) can work on code.


Messages In This Thread
Using <!--- ---> instead of <?php ?> in view files - by El Forum - 09-30-2008, 02:21 PM



Theme © iAndrew 2016 - Forum software by © MyBB