Welcome Guest, Not a member yet? Register   Sign In
Default Layout
#17

[eluser]mighty_falcon[/eluser]
[quote author="Dam1an" date="1244553275"]Can you post some code so I can get a better idea of what you mean?

The only things I could suggest off the top of my head is to make sure you decare the data variable in your class and then make it into an array
Code:
$data = array();

Not having that could cause some issues if you're running PHP4 I think (at least someone had that problem in the past and that was the cause)[/quote]

well my classes are exactly like the ones you posted in your example:

MY_Controller
Code:
class MY_Controller extends Controller {
    protected $data;
    protected $title;
    protected $view;
    
    
    
    /**
     * MY_Controller::__construct()
     *
     * Used to simply set-up the variables to be used when rendering the template.
     */
    public function __construct() {
        parent::Controller();
        // Initialise the default views
        //$this->views['menu'] = 'template/menu';
        //$this->views['sidebar'] = 'template/sidebar';
        //$this->views['main'] = 'template/main';
        //$this->views['footer'] = 'template/footer';
        
        // theme files go under controller/method
        $uri = $this->router->class.'/'.$this->router->fetch_method();
          $this->view = $uri;
          
          //sets the default title, each method should override this
          $this->title = '....title....';
  
    }
    
    /**
     * MY_Controller::render()
     *
     * @return: The default view for the main theme.
     *             Each subsequent view is then loaded via creating a folder and .php file in the view folder such as
     *
     *             CONTROLLER/METHOD.php
     */
    function render() {
        // We need the views and the data in the master template
        $this->load->view('main', array('data'=>$this->data, 'view'=>$this->view, 'title' => $this->title));
    }

the conroller file:
Code:
//helpers
        $this->load->helper('form');
        $this->load->helper('url');
        
        $popular_query = $this->db->query("SELECT term, COUNT(sid) AS total FROM searches GROUP BY term ORDER BY total DESC");
    

        $popular = $popular_query->result_array();
        
        $this->data = $popular;
        $this->title = 'test';

I cannot seem to be able to access any data i pass on to $this->data from the controller class...am i doing something wrong when extending MY_controller?


Messages In This Thread
Default Layout - by El Forum - 05-16-2009, 02:00 PM
Default Layout - by El Forum - 05-16-2009, 02:08 PM
Default Layout - by El Forum - 05-16-2009, 02:16 PM
Default Layout - by El Forum - 05-16-2009, 02:35 PM
Default Layout - by El Forum - 05-16-2009, 02:44 PM
Default Layout - by El Forum - 05-16-2009, 02:59 PM
Default Layout - by El Forum - 05-16-2009, 03:37 PM
Default Layout - by El Forum - 05-16-2009, 03:41 PM
Default Layout - by El Forum - 05-17-2009, 09:52 AM
Default Layout - by El Forum - 05-17-2009, 10:59 AM
Default Layout - by El Forum - 05-17-2009, 12:30 PM
Default Layout - by El Forum - 05-17-2009, 02:03 PM
Default Layout - by El Forum - 05-17-2009, 04:22 PM
Default Layout - by El Forum - 05-17-2009, 11:23 PM
Default Layout - by El Forum - 06-08-2009, 09:58 PM
Default Layout - by El Forum - 06-09-2009, 02:14 AM
Default Layout - by El Forum - 06-09-2009, 08:15 PM
Default Layout - by El Forum - 06-09-2009, 09:18 PM
Default Layout - by El Forum - 06-10-2009, 04:42 AM
Default Layout - by El Forum - 06-10-2009, 04:57 AM
Default Layout - by El Forum - 06-10-2009, 04:59 AM
Default Layout - by El Forum - 06-10-2009, 04:41 PM
Default Layout - by El Forum - 06-11-2009, 04:03 PM
Default Layout - by El Forum - 06-11-2009, 04:51 PM



Theme © iAndrew 2016 - Forum software by © MyBB