Welcome Guest, Not a member yet? Register   Sign In
How does it know which page to load?
#2

(03-05-2015, 12:17 PM)lexxtoronto Wrote: Ok, still reading the tutorial and trying to understand how the framework works


Code:
public function view($page = 'home')
{
...
}

So when you go to index.php/pages/view  then $title is home, which is clear, but when you go to index.php/pages/view/about   then $title is About.

How is it accomplished? Because here is explicitly says - function view($page = 'home')

Because home is defined as a default i.e. if you just did $this->view() then it would call 'home'. When you call $this->view('about') or
$myPage = 'about';
$this->view($myPage)

The default value is replaced with the value you passed in.

Think of $data as goodie-bag (in fact .NET MVC uses .bag in the same way). Everything you put into $data as part of the array, is delivered to the view and then unpacked back into it's own parameter so in the controller it is $data['title'] but in the view it is $title. In the controller it is $data['someArray']['keyvalue'] and in the view it is $someArray['keyvalue']
Reply


Messages In This Thread
RE: How does it know which page to load? - by obiron - 03-05-2015, 12:37 PM



Theme © iAndrew 2016 - Forum software by © MyBB