I’m developing a cms and I want the designer to be able to call all of the content while using an object called $view. My problem is that the included template-file can’t access the $view-object anymore.
The view object contains stuff like page_title(),… etc.
I also work with templates, so I want the designer to be able to call for the right template by accessing the $view object.
Some code to backup my explanation:
My library:
class view {
function page_title() {}
function template() {
$this->template = new template;
$this->template_include = $this->template->template_include();
}
}
class template {
function template_include(){
include('template.php');
}
}
My index-file:
$view = new view;
$view->template();
My template.php:
$view->page_title();
But I encountered a problem: The view object is created, then is, with a method from the view class, called for an object that, with the method template_include(), includes the right template.php. In this template I use the view-object again, in order to call for the right titles, content,…
My problem is that the included template-file can’t access the $view-object anymore.
Guess you all know the error:
Fatal error: Call to a member function field_title() on a non-object
I’m devoted to make this cms as easy as possible for the designer/user, so I only want the view-object to call for everything, without extra includes in the template-file etc…
Thanks!
You can pass the
$viewto the method/classIndex
Classes