Greg Schmidt wrote:
> I would like to start making substantial changes in the way functions output
> their output. Specifically, I want to eliminate all of the "print"
> statements, and instead have handlers build up output and return it. The
> code in index.php that calls the handler would get the output returned to
> it, and print it. Does this model fit in with the thoughts on templating?
> I think they are complementary changes, using a templating engine is just a
> different (hopefully better) way to generate the output within the handler.
> Any problems with my plan that I'm not seeing?
They are complimentary changes, but it probably doesn't make sense to
overhaul the output generation once to get rid of print and then a
second time to implement templating. It seems like less work to do the
templating at the same time.
I was thinking something like this:
1) index.php creates a Smarty object and passes it to the Handler at
construct time. The Handler makes this available via $this->smarty, as
well as a template filename accessible as $this->template_name
2) The concrete classes implementing handlers would set
$this->template_name to the appropriate template file name for whatever
is being done
3) Handler code calls Smarty's assign() method (ie:
$this->smarty->assign('name', $this->team->name) ) instead of building
up its own HTML for displaying that particular bit of information.
4) in index.php, instead of printing the result of $handler->process()
and the output theme_whatever() methods, we'd simply call:
$smarty->display( $handler->get_template_filename() );
and it does the right thing. To capture the output instead for use in
Zikula, you'd probably want $smarty->fetch(...) instead.
The get_template_filename() method is an idea I had for making the look
and feel more easily customizable -- it would first check a local
template directory for the file named by $handler->template_name, and if
none was found, fall back to whatever was shipped with Leaguerunner. It
could also optionally choose templates for a different language based on
the current user session, or whatever.
Cheers,
Dave
_______________________________________________
Leaguerunner mailing list
[email protected]
http://www.dmo.ca/cgi-bin/mailman/listinfo/leaguerunner