Welcome Guest, Not a member yet? Register   Sign In
Help using modular extensions please
#21

[eluser]k2zs[/eluser]
Is it possible to share views between modules?

Also I tried creating different routes for modules by adding a "config/routes.php" file to my modules and it didn't work.

I would like to have my main controller draw its contents from a database based on the first URI string so I found that to do so I have to have a route that points ":any" to "home" but in doing so none of my other controllers work.
#22

[eluser]k2zs[/eluser]
Also,

How can I use MY_Controller? I've had it try extending MX_Controller as well as Controller but nothing I put in it is available. Here is my last attempted MY-Controller file:

Code:
<?php (defined('BASEPATH')) OR exit('No direct script access allowed');

/* The MX_Controller class is autoloaded as required */
class MY_Controller extends MX_Controller
{
    // this method sets vars to be used by the main template, indicating the status of a cart with items in it
    public function __construct()
    {
        parent::__construct();
        // load this controllers model
        $this->load->model('Home_model');
        $this->load->model('Products_model');
        
        // load this controllers helpers
        $this->load->helper('text');
        
        // declare global variables activeCategory $templatePath
        $glodal_data['pgID'] = '';
        $glodal_data['formAction'] = '';
        $glodal_data['templateGlobals'] = $this->buildPage();
        $glodal_data['mainNav'] = $this->Home_model->getMainNav();
        $glodal_data['navBlock'] = array('components/side_mainNav','components/side_prodNav','components/side_linksNav','components/side_loginForm',);
        $glodal_data['contentBlock'] = array('components/body_contentView',);
        
        $this->load->vars($glodal_data);
    }
    
    
    
    
    // build default page content based on current URI
    function buildPage() {
        // Test for any segments in the uri and get the associated page
        if ($this->uri->total_segments() == 2) {
            // we got segments - lets get a page!
            $this->db->like('rootURI', $this->uri->segment(1));
            $this->db->like('pageURI', $this->uri->segment(2));
        } elseif ($this->uri->total_segments() == 1)    {
            // we got segments - lets get a page!
            $this->db->like('rootURI', $this->uri->segment(1));
        // If there are none load the default home page from the database
        } elseif ($this->uri->total_segments() == 0) {
            // set the default page to load
            //$this->db->where('pgType', 1);
            $this->db->where("pgType =1 AND parentID =0 AND pgNavOrder =1 LIMIT 1");
            //$this->db->order_by('pgNavOrder', 'asc');
        }
        $q = $this->db->get('pages');
        
        // If there are results
        if ($q->num_rows() > 0) {
            $data = $q->row_array();
        } else {
            // build empty results set
            $data = $this->buildFieldList();            
        }
        
        $this->load->vars($data);
        return;
    }
    
    
    // converts humanized page name to an acceptable URI string
    function build_uri($string){
      $slug = preg_replace('/[^A-Za-z0-9-]+/', '-', strtolower($string));
      return $slug;
    }
            
    // get total number of users
    function buildFieldList(){
        $fields = $this->db->list_fields('pages');
        foreach ($fields as $field)
        {
            $fieldArray = array(
                                $field => ''
            );
        }
        return $fieldArray;
    }
        
    // used for random data queriess
    public function getCustom($selectArray,$fromArray,$whereArray,$orderByArray) {

        $this->db->select($selectArray);
        $this->db->from($fromArray);
        $this->db->where($whereArray);
        $this->db->order_by($orderByArray, 'asc');
        
        $q = $this->db->get();
        // return result set as an associative array
        return $q->result_array();
    }
        
    // used for custom sql data queriess
    public function getCustomSql($sqlStatement) {
        
        $q = $this->db->query($sqlStatement);
        // return result set as an associative array
        return $q->result_array();
    }
    
    function testFunction($string) {
        $testRet = $string . $this->uri->total_segments();
        return $testRet;
    }
    
    
}
#23

[eluser]wiredesignz[/eluser]
Can you post the code for the controller(s) that extend MY_Controller?
#24

[eluser]k2zs[/eluser]
Wow... I thought I had tried that but when I did the HMVC didn't work so all my main controllers extended MX_. That was an easy fix as well Smile I think I'm getting it now.

So am I right now that only the module controllers extend MX_ ?
#25

[eluser]k2zs[/eluser]
OMG! They can ALL extend MY_Controller! This is great... In 1 or 2 days I've converted 2 cms sites to ME and developed a base design for all so that modules will interchange between applications...
#26

[eluser]wiredesignz[/eluser]
Any controller can extend MX_Controller.

If MY_Controller extends MX_Controller then any controller extending MY_Controller also has MX_Controller as a parent class.




Theme © iAndrew 2016 - Forum software by © MyBB