Date: 07/20/00
- Next message: Eric Ries: "Re: [phplib] Conditional blocks"
- Previous message: Zakaria: "Re: [phplib] Conditional blocks"
- In reply to: Zakaria: "Re: [phplib] Conditional blocks"
- Next in thread: Eric Ries: "Re: [phplib] Conditional blocks"
- Reply: Eric Ries: "Re: [phplib] Conditional blocks"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
* Zakaria <zak_mail <email protected>> [Jul 21 9:53am]:
> I second the motion.
I'm going to disagree here. I believe that ALL php code belongs in php
files and all HTML belongs in templates. No exceptions. As the highest
court in my land might say, "php in templates starts you on a
slipperly slope".
> Another use of having conditional in template is to separate the content
> and the formatting of HTML. That way you don't have to change
> the script if you want to change the template (big changes).
>
> For example you have template like this
> {ERROR_MSG}
> <table>... data ...</table>
>
> which ERROR_MSG is the message if there is an error or empty if there is
> no error. It's fine and dandy till your boss said he want the error message
> in Bold and red.
>
> So you have two choise you could change it in the code or you could add it
> in the template. Let just say you change the template to become like this:
> <b class="red_error">{ERROR_MSG}</b>
> <table>... data ...</table>
Not necessarily. I do this very same thing with every site I create.
Instead of {ERROR_MSG} being set via a set_var, conditionally decide
whether or not to parse it as its OWN TEMPLATE. Something like:
$tpl->set_unknowns("remove");
$tpl->set_file(array(error_msg => "error_msg.tpl"));
if (!empty($myError)) {
$tpl->set_var("ERROR_MSG_TXT", $myError);
$tpl->parse("ERROR_MSG", "error_msg");
}
error_msg.tpl would be:
<b class="red_error">{ERROR_MSG_TXT}</b>
while the main body template would be:
...
{ERROR_MSG}
... main page content ...
You can then easily change the contents of error_msg.tpl when your
boss wants the stop sign icon to the error message display. No need to
touch any PHP code.
If you didn't have unkowns set to remove, you could just set_var
ERROR_MSG to "" if you like.
-- Padraic Renaghan /pad-rik ren-a-han/ padraic <email protected> ICQ# 9437815 AOL IM: PadraicRenaghan http://renaghan.com/pcr/--------------------------------------------------------------------- To unsubscribe, e-mail: phplib-unsubscribe <email protected> For additional commands, e-mail: phplib-help <email protected>
- Next message: Eric Ries: "Re: [phplib] Conditional blocks"
- Previous message: Zakaria: "Re: [phplib] Conditional blocks"
- In reply to: Zakaria: "Re: [phplib] Conditional blocks"
- Next in thread: Eric Ries: "Re: [phplib] Conditional blocks"
- Reply: Eric Ries: "Re: [phplib] Conditional blocks"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

