Page 2 of 2

Re: View (MVC) Function / Class

Posted: Wed Nov 05, 2008 7:16 pm
by allspiritseve
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.

Re: View (MVC) Function / Class

Posted: Thu Nov 06, 2008 2:39 am
by Christopher
And for the record, allspiritseve's createTabs() function would be the "View".

Re: View (MVC) Function / Class

Posted: Thu Nov 06, 2008 8:38 am
by psurrena
Looks great, I'll implement it later today and see how it goes. Thanks again!

Re: View (MVC) Function / Class

Posted: Thu Nov 06, 2008 8:43 am
by psurrena
One question, why is tabcount listed twice, in two forms?

Code: Select all

$template->set ('tabCount', $tabCount);

Re: View (MVC) Function / Class

Posted: Thu Nov 06, 2008 8:56 am
by allspiritseve
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.

Re: View (MVC) Function / Class

Posted: Fri Nov 07, 2008 10:14 am
by psurrena
Great, thanks a lot.