Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.
Moderator: General Moderators
allspiritseve
DevNet Resident
Posts: 1174 Joined: Thu Mar 06, 2008 8:23 am
Location: Ann Arbor, MI (USA)
Post
by allspiritseve » Wed Nov 05, 2008 7:16 pm
psurrena wrote: oh, and I might have made fun of this but it has just saved me a ton of work. It must be worth something
If you combine what arborint and I posted, you may find that this is a bit cleaner:
Code: Select all
public function createTabs ($tabCount) {
$template = new Template ('tabs.tpl');
$template->set ('tabCount', $tabCount);
return $template->render();
}
Assuming the Template class is arborint's phpTemplate class, and tabs.tpl contains my html+presentational php.
Christopher
Site Administrator
Posts: 13596 Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US
Post
by Christopher » Thu Nov 06, 2008 2:39 am
And for the record, allspiritseve's createTabs() function would be the "View".
(#10850)
psurrena
Forum Contributor
Posts: 355 Joined: Thu Nov 10, 2005 12:31 pm
Location: Broolyn, NY
Post
by psurrena » Thu Nov 06, 2008 8:38 am
Looks great, I'll implement it later today and see how it goes. Thanks again!
psurrena
Forum Contributor
Posts: 355 Joined: Thu Nov 10, 2005 12:31 pm
Location: Broolyn, NY
Post
by psurrena » Thu Nov 06, 2008 8:43 am
One question, why is tabcount listed twice, in two forms?
Code: Select all
$template->set ('tabCount', $tabCount);
allspiritseve
DevNet Resident
Posts: 1174 Joined: Thu Mar 06, 2008 8:23 am
Location: Ann Arbor, MI (USA)
Post
by allspiritseve » Thu Nov 06, 2008 8:56 am
psurrena wrote: One question, why is tabcount listed twice, in two forms?
Code: Select all
$template->set ('tabCount', $tabCount);
One's the key, one's the value. That way you can tell the template class what to name the variable when it passes control over to the included form. Look up the extract() function in the php manual, you'll see what it does. It's pretty handy.
psurrena
Forum Contributor
Posts: 355 Joined: Thu Nov 10, 2005 12:31 pm
Location: Broolyn, NY
Post
by psurrena » Fri Nov 07, 2008 10:14 am
Great, thanks a lot.