Welcome Guest, Not a member yet? Register   Sign In
model inheritance: extending a model that already extents from ci_model
#1

[eluser]obiron2[/eluser]
Guys,

Long time no post.

Background to the question:
I am building a website based on a CSS template that emulates Windows 8 Metro UI interface. There are different types of tiles (regular tile, picture rotator, Icon tiles, social feed tiles etc) Each tile has specific properties and methods but there are some common features so I think they make a good candidate for a tile class and then separate classes for the specific tile types which inherit from the tile class. My first prototype has the tile built extending the ci_model

Code:
class tile_model extends CI_model{

public $type = "tile";
public $name;
public $icon;;
  ...
function add_css($classname){...}
function render(){...}
...
}

What I now want to do is

Code:
class image_rotator_tile_model extends tile_model{
public var $images = array(); // this is a new property
...
function add_image($name,$alttag,$link){ // this is a new function
...
}
function render(){ //this overloads the standard function
...
}
}

Codeigiter is throwing me an error
Fatal error: Class 'tile_model' not found in C:\xampp\htdocs\application\models\image_rotator_tile_model.php ...

I know that I can't inherit from tile_model so what do I need to do to make this work?
#2

[eluser]obiron2[/eluser]
Worked it out!

I need to manually add the require_once() to the tile_model.php file

I got the answer from here
http://net.tutsplus.com/tutorials/php/6-...e-masters/

They show a techinique for autoloading non CI base classes but this is beyond what I need to do (for now)




Theme © iAndrew 2016 - Forum software by © MyBB