Welcome Guest, Not a member yet? Register   Sign In
Call extend class.
#1

[eluser]Lazos[/eluser]
If I want to use the Content library I load it from the controller or the autoload file and then just write $this->Class->method();

If I want to call the extend class of the Content class how I do it?

Code:
<?php

class Content {
    
    var $userid;
    var $contenttype;
    var $title;
    var $menutext;
    var $parent;
    var $content;
    var $active;
    var $showinmenu;
    var $target;
    var $pagealias;
    var $description;
    var $editors;
    var $modified_date;
    var $modified_user;
    var $root;
    
    function __construct() {
        $this->SetInitialValues();    
        
    }
    
    function SetInitialValues() {
    
        $this->title = "";
        $this->menutext = "";
        $this->parent = "";
        $this->content = "";
        $this->active = "";
        $this->showinmenu = "";
        $this->target = "";
        $this->pagealias = "";
        $this->description = "";
        $this->editors = array();
        $this->modified_date = getdate();
        $this->modified_user = "";    
    }

    function getContentTypes($root){
        $this->root = $root;
        $dh = @opendir($root.'/application/views/admin/content/');
        $i = 0;
        while (false !== ($file = readdir($dh))){
            $filename = strtolower(substr($file, 0, strpos($file, '.')));
                if(!is_dir($file)){    
                $array['repeat_type'][$i]['V_CONTENT_TYPE_NAME'] = ucwords($filename);
                $i++;
            }        
        }
        closedir( $dh );
        $this->contenttype = $array;
        return $array;
    }
}

class Newcontent extends Content {
    
        function __construct() {
        }
        
        function getDate() {
         return $this->modified_date;
        }
        
}
?>
#2

[eluser]Sumon[/eluser]
have a try
Code:
class Newcontent extends Content {
    
        function __construct() {
            $this->SetInitialValues();
        }
        
        function getDate() {
         return $this->modified_date;
        }
        
}
$x = new Newcontent();
print_r($x->getDate());
Content class __construct() not called anywhere. so that explicit call of SetInitialValues() resolve the issue.
may be helpful for you Smile
#3

[eluser]Lazos[/eluser]
Hey thanks for your reply.
Inside my controller I have $this->load->library(content); the constructor is not called when the class is loaded?




Theme © iAndrew 2016 - Forum software by © MyBB