[dev] interesting article on templates

Nuno Loureiro nuno at co.sapo.pt
Thu Sep 18 04:25:04 PDT 2003


On Wed, 2003-09-17 at 18:18, Chuck Hagenbuch wrote:
> Quoting Nuno Loureiro <nuno at co.sapo.pt>:
> 
> > There's no business logic in this, there's a presentation logic only.
> > But that doesn't mean that both logic are separated, because these are
> > methods of classes that constitutes the core of Horde, that belong to
> > the global business logic of the application. I mean, if you want to
> > change the layout of this you have to put your hands on the code, not on
> > the templates as it should be.
> 
> Still, they are logic, and you don't want to rip out those functions and just
> put them into the templates - you'd be massively increasing the size and
> complexity of the templates. So there have to be UI libraries somewhere -
> Horde:: isn't the right ending place for them, but in some kind of layout class
> *is*. Just templates isn't the answer.

I really don't understand the problem of having such logic in templates.
I'll give you an example of setting an item of the menu in the php file,
and the respective block in the template.

 $menu[] = array('url' =>
Horde::nocacheUrl(Horde::applicationUrl('folders.php')), 'text' =>
_("Folders"), 'icon' => 'folders.gif', 'icon_path' => $registry-
>getParam('graphics'), 'id' => 'folders', 'active' => true);

In the end of defining all these menu items I do have a foreach to
define them in the template, and to set the key 'status' in the array.

--------
<loop:mitem_folders>
  <if:mitem_folders.active>
    <td align="center" nowrap="nowrap" valign="<tag:menu_view />"
class="<tag:mitem_folders.status />"><a href="<tag:mitem_folders.url
/>"  onmouseout="window.status='';"
onmouseover="window.status='<tag:mitem_folders.text />'; return
true;" class="menuitem" accesskey="<tag:mitem_folders.accesskey />"
target="<tag:mitem_folders.target />"><tag:mitem_folders.button
/></a>&nbsp;</td>
  </if:mitem_folders.active>
</loop:mitem_folders>

Having classes to produce output, I think it's the opposite philosophy
of this. You have these 2 types of philosophys and you should decide
which one you want. Think awhile about this..

It's difficult to change the design, if you have to change plenty of
different files. Take as an example an horde page like mailbox.php. You
have HTML output on several locations, like the menu stuff
(lib/Menu.php), the notification stuff
(lib/Notification/Listener/status.php), the quota stuff (imp/lib/Quota),
and each one of the current template files. There are more problems
about this that I told you previously, like you can't give this to a
designer to change the layout (because he has to know PHP and search the
code for HTML output), and you can't have 2 different sites using the
same base (framework+core).

> If you have the time to be a bit patient, I'd like to really work on this and
> work off of your work with IMP. Let's see if we can come up with a really nice,
> clean, fast solution that'll be applicable to other Horde applications, too.

I have, and I don't. I'll explain. I don't, because I need to have this
done by the end of the next week (otherwise, I'll compromise the launch
of the project), and I have, because at least after I've done my
version, I can continue to work on this without a limit in time. I just
need to find a way about how can I work on this and submit future work,
because sometime in the next week, I'll need to branch this on a
separate cvs server, so I can implement internal specific features that
don't make sense at all to contribute to Horde.


-- 
Nuno Loureiro <nuno at co.sapo.pt>
PTM.com - http://www.sapo.pt/
PGP fingerprint = 8A32 5174 E80C 2D40 9075 405E C107 6592 054A 4D05



More information about the dev mailing list