CodeIgniter Forums

Full Version: Edit Page Issue
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8

El Forum

[eluser]jzmwebdevelopement[/eluser]
I get the following:
Code:
array(6) { [0]=> object(stdClass)#23 (5) { ["id"]=> string(1) "1" ["name"]=> string(4) "Home" ["permalink"]=> string(4) "home" ["content"]=> string(21) "This is the home page" ["template"]=> string(4) "home" } [1]=> object(stdClass)#24 (5) { ["id"]=> string(1) "2" ["name"]=> string(8) "About Us" ["permalink"]=> string(8) "about-us" ["content"]=> string(9) "About us " ["template"]=> string(7) "default" } [2]=> object(stdClass)#25 (5) { ["id"]=> string(1) "3" ["name"]=> string(7) "Gallery" ["permalink"]=> string(7) "gallery" ["content"]=> string(7) "Gallery" ["template"]=> string(7) "default" } [3]=> object(stdClass)#26 (5) { ["id"]=> string(1) "4" ["name"]=> string(13) "Testimonials " ["permalink"]=> string(12) "testimonials" ["content"]=> string(13) "Testimonials " ["template"]=> string(7) "default" } [4]=> object(stdClass)#27 (5) { ["id"]=> string(1) "5" ["name"]=> string(5) "Sales" ["permalink"]=> string(5) "sales" ["content"]=> string(20) "Sales loaded from DB" ["template"]=> string(5) "sales" } [5]=> object(stdClass)#28 (5) { ["id"]=> string(1) "6" ["name"]=> string(7) "Contact" ["permalink"]=> string(10) "contact-us" ["content"]=> string(10) "Contact Us" ["template"]=> string(7) "default" } }

El Forum

[eluser]toopay[/eluser]
Then it works!

Put
Code:
$CI =& get_instance();
$CI->load->model('navigation_model');
in controller's constructor function, uncomment above function to enable back your block of code, then test it.

El Forum

[eluser]jzmwebdevelopement[/eluser]
Still not working,

I have put:
Code:
function __construct(){
        parent::__construct();
        
        $CI =& get_instance();
        $CI->load->model('navigation_model');
    }
    
    public function index(){

        if($this->session->userdata('logged_in')) redirect('admin/dashboard');
        // set data
        $data['title'] = 'Login';
        $data['sales_pages'] = NULL;
        $data['get_images'] = NULL;
        $data['cms_pages'] = $this->navigation_model->getCMSPages();

        // load partial view - EAMPLE
        // view path,  data to pass in ( NULL, array or object ), TRUE returns as a varialble, else echo's.
        $data['content'] = $this->load->view('admin/admin_login', NULL, TRUE);
        // THEN load view.
        $this->load->view('template', $data);

    }

El Forum

[eluser]toopay[/eluser]
Unblievable!

How about this.
Code:
//....
    protected $_CI;
    function __construct(){
        parent::__construct();
        // get a copy of CI instances
        $this->_CI =& get_instance();
        $this->_CI->load->model('navigation_model');
    }
    
    public function index()
    {
        if($this->session->userdata('logged_in')) redirect('admin/dashboard');
        // set data
        $data['title'] = 'Login';
        $data['sales_pages'] = NULL;
        $data['get_images'] = NULL;
        $data['cms_pages'] = $this->_CI->navigation_model->getCMSPages();

        // load partial view - EAMPLE
        // view path,  data to pass in ( NULL, array or object ), TRUE returns as a varialble, else echo's.
        $data['content'] = $this->load->view('admin/admin_login', NULL, TRUE);
        // THEN load view.
        $this->load->view('template', $data);
    }

El Forum

[eluser]jzmwebdevelopement[/eluser]
I have been trying to work this out for myself for the last few days, Sadly that did not work Sad

El Forum

[eluser]toopay[/eluser]
Don't tell me this not working too...
Code:
//On Model
    function getCMSPages()
    {
        $query = $this->db->get('pages');
        return $query->result_array();
    }
//On 'Home' Controller
    function __construct(){
        parent::__construct();
    }
    
    public function index()
    {
        $CI =& get_instance();
        $CI->load->model('navigation_model');
        if($this->session->userdata('logged_in')) redirect('admin/dashboard');
        // set data
        $data['title'] = 'Login';
        $data['sales_pages'] = NULL;
        $data['get_images'] = NULL;
        
        $data['cms_pages'] = $this->navigation_model->getCMSPages();

        // load partial view - EAMPLE
        // view path,  data to pass in ( NULL, array or object ), TRUE returns as a varialble, else echo's.
        $data['content'] = $this->load->view('admin/admin_login', NULL, TRUE);
        // THEN load view.
        $this->load->view('template', $data);
    }

El Forum

[eluser]jzmwebdevelopement[/eluser]
If you heard screaming that was me Smile -> nope

El Forum

[eluser]toopay[/eluser]
:gulp: Ok, let's try it SLOWLY . Let's we back and run this, (keep your model's function like above.)
Code:
//...
    public function index()
    {
        $CI =& get_instance();
        $CI->load->model('navigation_model');
        var_dump($this->navigation_model->getCMSPages());
        exit;
        /* Temporary disable this block
        if($this->session->userdata('logged_in')) redirect('admin/dashboard');
        // set data
        $this->load->model('navigation_model');
        $data['title'] = 'Login';
        $data['sales_pages'] = NULL;
        $data['get_images'] = NULL;
        $data['cms_pages'] = $this->navigation_model->getCMSPages();

        // load partial view - EAMPLE
        // view path,  data to pass in ( NULL, array or object ), TRUE returns as a varialble, else echo's.
        $data['content'] = $this->load->view('admin/admin_login', NULL, TRUE);
        // THEN load view.
        $this->load->view('template', $data);
        */
    }

El Forum

[eluser]jzmwebdevelopement[/eluser]
Ok,

I put the above code into my editpage.php file and it outputted:
Code:
array(6) { [0]=> array(5) { ["id"]=> string(1) "1" ["name"]=> string(4) "Home" ["permalink"]=> string(4) "home" ["content"]=> string(21) "This is the home page" ["template"]=> string(4) "home" } [1]=> array(5) { ["id"]=> string(1) "2" ["name"]=> string(8) "About Us" ["permalink"]=> string(8) "about-us" ["content"]=> string(9) "About us " ["template"]=> string(7) "default" } [2]=> array(5) { ["id"]=> string(1) "3" ["name"]=> string(7) "Gallery" ["permalink"]=> string(7) "gallery" ["content"]=> string(7) "Gallery" ["template"]=> string(7) "default" } [3]=> array(5) { ["id"]=> string(1) "4" ["name"]=> string(13) "Testimonials " ["permalink"]=> string(12) "testimonials" ["content"]=> string(13) "Testimonials " ["template"]=> string(7) "default" } [4]=> array(5) { ["id"]=> string(1) "5" ["name"]=> string(5) "Sales" ["permalink"]=> string(5) "sales" ["content"]=> string(20) "Sales loaded from DB" ["template"]=> string(5) "sales" } [5]=> array(5) { ["id"]=> string(1) "6" ["name"]=> string(7) "Contact" ["permalink"]=> string(10) "contact-us" ["content"]=> string(10) "Contact Us" ["template"]=> string(7) "default" } }

So I know its working,

I then proceeded to try to pass the page /home and soon as I hit enter I got the
Code:
PHP Fatal error:  Call to a member function getCMSPage() on a non-object
error, could it be something to do with the uri not being passed through?

El Forum

[eluser]toopay[/eluser]
editpage.php? I think we are in 'home.php'. Are you mean you try the param crossing a controller?? How you passed it, post another corresponding controller?

Please, give the clear information. I'm not an expert fortune-telling which know what in your mind, so dont say just "PHP Fatal error: Call to a member" when in fact, you receive 500 internal server error, and so on.
Pages: 1 2 3 4 5 6 7 8