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]toopay[/eluser]
Is this generates error too?
Code:
//...
    function index(){
        if(!$this->session->userdata('logged_in'))redirect('admin/home');
        // Just to ensure
        $CI =& get_instance();
        $CI->load->model('navigation_model');
        var_dump($this->navigation_model->getCMSPage('home'));
        /*
        $page = $this->navigation_model->getCMSPage($this->uri->segment(3));
        $data['cms_pages'] = $this->navigation_model->getCMSPages();
        $data['title'] = $page['name'] ? $page['name'] : 'Something wrong';
        $data['content'] = $this->load->view('admin/editpage', array('page' => $page, TRUE));
        $this->load->view('admintemplate', $data);
        */
    }

El Forum

[eluser]jzmwebdevelopement[/eluser]
right we are now getting somewhere

when I used the above code and accessed domain.co.nz/editpage/

I got
Code:
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" }

but when I tried to pass the "page" pram I still got the fatal error.

El Forum

[eluser]toopay[/eluser]
rename $page to something else!$mypage or whatever!

El Forum

[eluser]jzmwebdevelopement[/eluser]
I renamed $page to $mypage and I am still not able to pass the prama

El Forum

[eluser]toopay[/eluser]
Continue debug it... try this
Code:
//...
    function index(){
        if(!$this->session->userdata('logged_in'))redirect('admin/home');
        // Just to ensure
        $CI =& get_instance();
        $CI->load->model('navigation_model');
        $mypage = (array) $this->navigation_model->getCMSPage('home');
        var_dump($mypage);
        /*
        $page = $this->navigation_model->getCMSPage($this->uri->segment(3));
        $data['cms_pages'] = $this->navigation_model->getCMSPages();
        $data['title'] = $page['name'] ? $page['name'] : 'Something wrong';
        $data['content'] = $this->load->view('admin/editpage', array('page' => $page, TRUE));
        $this->load->view('admintemplate', $data);
        */
    }

El Forum

[eluser]jzmwebdevelopement[/eluser]
The above code outputted

Code:
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" }

I just cannot understand why I cannot pass the permalink and call the above data

El Forum

[eluser]toopay[/eluser]
Then debug it!
Code:
//...
    function getCMSPage($permalink = '')
    {
        $foo = $permalink != '' ? $permalink : 'home';
        $query = $this->db->where('permalink', $foo)
                          ->get('pages');
        $res = $query->result_array();
        return count($res)>0 ? $res[0] : 'No result';
    }

El Forum

[eluser]jzmwebdevelopement[/eluser]
ok,

The debug code above showed the homepage content in the text area under the editpage, but I am still getting the Fatal Error when I pass the correct param into the url

El Forum

[eluser]toopay[/eluser]
What this result...
Code:
//...
    function index(){
        if(!$this->session->userdata('logged_in'))redirect('admin/home');
        // Just to ensure
        $CI =& get_instance();
        $CI->load->model('navigation_model');
        $mypage = (array) $this->navigation_model->getCMSPage('home');
        var_dump($mypage);
        var_dump($this->uri->segment(3));
        /*
        $page = $this->navigation_model->getCMSPage($this->uri->segment(3));
        $data['cms_pages'] = $this->navigation_model->getCMSPages();
        $data['title'] = $page['name'] ? $page['name'] : 'Something wrong';
        $data['content'] = $this->load->view('admin/editpage', array('page' => $page, TRUE));
        $this->load->view('admintemplate', $data);
        */
    }

El Forum

[eluser]jzmwebdevelopement[/eluser]
Result is
Code:
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" } bool(false)
Pages: 1 2 3 4 5 6 7 8