On Thu, 18 Nov 2004 22:30:16 -0800 (PST), Peter Speltz wrote
> I'm not experience enought to comment on much here but you did
> inspire one idea regarding template root. In short I request an
> interface to at least unshift and push template paths onto the list
> from the Model.
>
> It would be good to have template root be modifiable at run time by
> the MODEL. Take the handheld device example -- you want a compact
> version of the page for handhelds. It would get pretty tedious
> checking the user agent and setting the template in every model sub.
IMO, the model shouldn't be affecting the view like that. That seems like
presentation logic that belongs in a custom view or perhaps the controller.
Here's one way of doing it as a custom view:
package MyView; # or whatever
use base 'Maypole::View::TT';
use File::Spec;
sub paths {
my ($self, $r) = @_;
my @paths = $self->SUPER::paths($r);
my $platform = 'web';
if ($ENV{USER_AGENT} =~ /Nokia|Motoroloa|.../) {
$platform = 'mobile';
}
return map File::Spec->catdir($_, $platform), @paths
}
That's just an example (untested, of course). But in the example, the view
itself is looking at the user agent and appending a platform to the folder
structure. So it'd return something like this:
templates/$platform/
templates/$model/$platform/
templates/custom/$platform/
templates/factory/$platform/
Now the presentation logic is happening in one place in your code. In your
model, you just call $r->template('list') and make sure that you have
appropriate templates for both platforms. The view takes care of the rest.
There are other ways of doing this in the existing framework, for example,
by overriding Maypole::get_template_root().
--simonflk
_______________________________________________
maypole mailing list
maypole at lists.netthink.co.uk
http://lists.netthink.co.uk/listinfo/maypole
This archive was generated by hypermail 2.1.3 : Thu Feb 24 2005 - 22:25:57 GMT