Welcome Guest, Not a member yet? Register   Sign In
Matchbox RC2
#41

[eluser]gerben[/eluser]
Thanx for all the effort you're putting into this.
#42

[eluser]esra[/eluser]
[quote author="gerben" date="1196555143"]Sorry, I'm still figuring out how to load the view library.

I've created a folder called libraries in my module folder, and put the view library in there. But how do I load it in the controller?[/quote]

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

require(APPPATH.'libraries/application'.EXT);

class Frontpage extends Application {

    public function __construct()
    {
        parent::__construct();    
        $this->lang->load('frontpage', 'en_US');    
        $this->load->model('frontpage_model');
    }
    
    public function index()
    {
        $module = $this->lang->line('frontpage_module');
        $page = $this->lang->line('frontpage_title');
        
        $this->view->set('title', $page);
        $this->view->set('module', $module);
        $this->view->part('west', 'west');
        $this->view->part('north', 'north');
        $this->view->part('center2', 'center2');
        $this->view->part('center1', 'center1');
        $this->view->part('east', 'east');
        $this->view->part('south', 'south');
        $this->view->load('complex');
    }
}
#43

[eluser]zdknudsen[/eluser]
Hm. It should work (just tried it myself) :S Basicly what happens is:

You have the view library in the standard application folder. That means whenever you $this->view->load(), it will call the view library, that in turn will call the usual loader function. Now, when Matchbox tries to find out if it was a module that requested a view, it will think that the view library did so, and that view library is located in the application folder. Therefore it cannot find your view in the module folder. However, if you place your View libary in the module folder instead, Matchbox will know what module to look for the view in.

Depending on how you wish to load it you can either $this->load->library('View') in the controller, or if you wish to autoload the library you will have to insert $autoload['libraries'] = array('MODULENAME' => 'View') instead of $autoload['libraries'] = array('View');

esra: Is that a working example, meaning that what he is trying to accomplish is doable?
#44

[eluser]gerben[/eluser]
Ok, if I put the view library in my module's library folder, and in the controller I put:

Code:
$this->load->library('View');

I get the error:

Cannot redeclare class View in
xxxx/site/app/modules/api/libraries/View.php on line 11
#45

[eluser]zdknudsen[/eluser]
I think you might also be autoloading it. You can't both autoload it and load it in the controller.
#46

[eluser]gerben[/eluser]
I'm autoloading it for the main app, not for the modules. So I have to remove it from my main autoload file in applications/config/, and then load it in all controllers in my main app and modules? That means that if I want to autoload it for my main app controllers, I can't autoload it for my modules, and vice versa? Is that correct?
#47

[eluser]zdknudsen[/eluser]
That is correct and I see your point. Well, as far as I know CI shouldn't fail just because you already loaded a clas.. Perhaps I've done something wrong somewhere. *takes one more look at Loader.php*

Ah yes. CodeIgniter doesn't store a list of loaded classes. It stores a list of the filepaths to the classes (wierd...). I've made a new commit to the svn where itll store just the class name instead.

Overwrite your MY_Loader.php with this one: http://matchbox.googlecode.com/svn/trunk...Loader.php

It'll be included in the next release as well.
#48

[eluser]gerben[/eluser]
Still no luck, I'm afraid. I've autoloaded the view library for the main app, and used $this->load->library('View'); for the module controllers.

I don't get the "already loaded" message, but I just get the old: Unable to load the requested file: settings.php

Maybe I should give it a rest and look at this later? It's so strange it keeps on not working.
#49

[eluser]zdknudsen[/eluser]
Must be because it's using the autoloaded one.

We'll I've figured out how to cope with this (and future similar issues), it's a little hard to explain so I'll need to document it. Basicly there is going to be another config item with some stuff to configure regarding this. However, I'm not going to get this done untill tomorow so yes you might just as well give it a rest.

Check back tomorrow.
#50

[eluser]gerben[/eluser]
Okay, so you think it's a issue that might happen with other libraries as well. Anyway, thanx so much for your help, I really appreciate it!

I'll check back tomorrow-night or monday.




Theme © iAndrew 2016 - Forum software by © MyBB