[eluser]Bleeding Edge Productions[/eluser]
Hi guys,
First off, thanks to those who have taken the time to respond to my questions so far. Apologies for another newbie problem here...
I have a controller "Homepage" which extends "MY_Controller" (which extends "Controller").
In homepage I have several page-specific variables defined:
Code:
protected $page_id = 'home'; // Page reference ID
protected $page_title = 'Home'; // Page title for <title> tag
protected $parent_id = ''; // Parent page ID if child (null if page is parent)
protected $h1_text = "Hi! I'm Martin"; // Text used for <h1> with CSS turned off
protected $page_color = '#0d507a'; // Page colour scheme
protected $bg_position = '560px 0px'; // Background image CSS position - left, top
protected $h1_margins = '30px 0px 40px 0px'; // <h1> image CSS position - top, right, bottom, left
protected $meta_description = 'Description'; // Meta description
protected $meta_keywords = 'Keywords'; // Meta keywords
protected $meta_robots = 'INDEX,FOLLOW'; // Meta robots
As part of the index() method in the Homepage class, I have a couple of routines to do things like get the heading 1 image size:
Code:
/**
* Get the heading 1 image CSS size attributes
* using the img_css_size() helper
*/
$h1_fullpath = $this->base . $this->assets . "img/pages/" . $this->page_id . '-h1.png';
$h1_css_size = img_css_size($h1_fullpath);
and generate the page title:
Code:
/**
* Page <title> tag
*
* If there is a parent, include that in the <title>
*/
if (empty($this->parent_id)) {
$full_page_title = $this->site_name . ' | ' . $this->page_title;
}
else {
$full_page_title = $this->site_name . ' | ' . $this->parent_title . ' | ' . $this->page_title;
}
etc.
The problem is, I am going to need these routines in ALL my controllers (Homepage, About, Work, Biog, etc etc.). I'd really like to put them in MY_Controller (the parent controller), but most of the variables are page specific (this->page_id etc.), and only set in the controller which EXTENDS MY_Controller.
Is there a way to do this?
Many thanks,
Martin