Welcome Guest, Not a member yet? Register   Sign In
Dynamic Pages and Modules
#1

[eluser]sunnyd[/eluser]
I have been struggling with this for a while and I cant seem to find a way to resolve it. I am quite simply trying to create my own CMS and I am making use of the Modular Separation library for my modules.

I have created the dynamic pages and they are loading perfectly. But when I try to load a module, all i keep getting is 404 error. Now I have looked at the _remap function, and I am still lost as to how to fix the issue.

This is my code.. (apologies if this is already way way back in the forums)

Code:
class Page extends MY_Controller {
    
    function __construct() {
        parent::__construct();
    }
    
    public function _remap($method)
    {
       if (method_exists($this, $method)){
        $this->$method($this->uri->segment(1));
       } else {
        $this->index($method);
       }      
    }
    
    public function index() {
        $pageSlug = $this->uri->segment('1'); // Grab the URI segment
        // var_dump($pageSlug);
        $this->showPage($pageSlug);
    }
    
    protected function showPage($pageSlug) {
        $data              = array();    
        $data['title']       = "kaosCMS";
        $data['meta']     = array(
                                    array('name' => 'robots', 'content' => 'no-cache'),
                                    array('name' => 'description', 'content' => 'My Great Site'),
                                    array('name' => 'keywords', 'content' => 'love, passion, intrigue, deception'),
                                    array('name' => 'robots', 'content' => 'no-cache'),
                                    array('name' => 'Content-type', 'content' => 'text/html; charset=utf-8', 'type' => 'equiv')
                                );
        // $data['main_nav'] = $this->navigation_model->display_main_nav();
                
        if (!$pageSlug)
        {
            $pageSlug = (int)$pageSlug ? '1' : 'home';
        }
        
        $dataPage = $this->page_model->getPage($pageSlug); // Pull the page data from the database
        // var_dump($dataPage);    
        // Taken out || ($pageSlug !== $dataPage->pge_slug)
        if ((empty($dataPage)) || ($dataPage->pge_status == 'unpublished'))
        {
            show_404($pageSlug); // Show a 404 if no page exists
            // show_error('The page you are looking for does not exist!');
        }
        else
        {
            $data['content'] = $this->load->view('index', $dataPage , TRUE);
            // var_dump($dataPage);
            // $this->load->view('index', $dataPage);
            $this->load->view($this->template, $data);
        }
    }
}

the code above works when I want to load dynamic pages. But I cant load modules. Can anyone enlighten me on this aspect of things...

Many Thanks, Sunnyd
#2

[eluser]Unknown[/eluser]
I want to do this too, who can help?




Theme © iAndrew 2016 - Forum software by © MyBB