You can’t use $this->load->module() inside a view. Instead check out the modules_helper
$result = modules::run('cl_auth', NULL, 'isValidUser');This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
March 03, 2008 6:10pm
Subscribe [48]#631 / Aug 21, 2008 12:53pm
You can’t use $this->load->module() inside a view. Instead check out the modules_helper
$result = modules::run('cl_auth', NULL, 'isValidUser');#632 / Aug 21, 2008 1:35pm
Thanks for the help! I got it all working 😊. Even with using the Template Class by Colin Williams. I never thought that would happen haha. It’s 2:30am so I’m headed to bed. Thanks again 😊.
#633 / Aug 22, 2008 9:00am
Well I got it all ported over and everything works great 😊. Having a small problem though. I had to move all the config file arrays over to the main config file as I wasn’t able to call any of the variables with $this->config->item(‘whatever’). I looked at the debug and it said that it was loading the module’s config file but it still didn’t work. Although, was I supposed to get the config variables like this $this->module_name->config->item(‘whatever’)? Guess I should have tried that before I moved all them over heh.
Also, I see back on page 30-something of this post that you are able to have sub-directories in your views folder in your module directory. But you said something that the view files have to be named the same as the controller? Or is that the sub-directory has to be named the same as the controller? The reason I ask is I’m using views as templates for emails that get sent out and it would be nice to have them in a directory named ‘email’ in the views directory.
Anyways, thanks again for Modular Extensions. I’m really digg’n it!
#634 / Aug 22, 2008 9:26am
Hi again,
You can load config items from modules however the module script creates a config sub-array for your items by default. (prevents your items from over-writing CI’s)
To retrieve a config item you must also specify the config file name you loaded.
$this->config->item('item', 'filename');Views in sub-directories is also possible, the sub-directory name must match the controller name.
Good luck. 😉
#635 / Sep 10, 2008 5:28pm
wired…
i’m having an issue with routing that i can’t quite get under. can you please help?
i’ve got two modules i built - both of them i’ve posted here in this very thread 😊 :
pages (for serving views as requested on the URI)
photobox (for a simple photogallery built from a directory of jpgs)
here is my routes.php file:
$route['default_controller'] = "pages";
$route['scaffolding_trigger'] = "";
// route everything to pages, except requests to photobox
$route['photobox/(.*)'] = "photobox/$1";
$route['(.*)'] = "pages/$1";i want everything that is not photobox to go to pages. and everything that is targeting photobox to be passed along to it.
so, each of those “custom routes” works when i comment the other. but, when i have both active, the pages route works but the photobox one doesn’t. it gives me a 404 and shows the server path as if it is looking for photobox *inside* the pages module (as if it were a view file!).
the problem seems to be in the _validate_request() method the MY_Router.php. take a look at the $segments array that is passed in when these two routes are active:
Array ( [0] => pages [1] => photobox )it shows pages as the 0th array item! i suppose that is correct since it is the default_controller, but the code in the _validate_request() method really doesn’t know what to do with that.
here, the method tries to use the 0th element as a path parameter.
/* locate the module controller */
list($path, $file, $home) = $this->find($segments[1], $segments[0]);i think that this method is making an assumption… but, i can’t figure out what the assumption is. 😉
can you take a look and let me know if you see something obvious.
thx.
EDIT: i just discovered that i can get it to work by adding a literal route first… but, i don’t want to do that for every module. shouldn’t it work without having to add two routes per “second tier” modules (the ones that aren’t the main static site served up by the pages module)?
// route everything to pages, except requests for photobox
$route['photobox'] = "photobox";
$route['photobox/(.*)'] = "photobox/$1";
$route['(.*)'] = "pages/$1";#636 / Sep 10, 2008 7:34pm
Hi Sophistry,
A single regex to catch anything `photobox` related would be like so:
$route['photobox(.*)'] = "photobox$1";Hope this helps.
#637 / Sep 11, 2008 1:19am
ok, well, that worked, but, how? i’ve never seen a regex omit the slash and re-embed it using the backreference.. i suppose i thought it wouldn’t work so i never tried it. and i am pretty good with regex if i do say so myself. 😉
my routing is specific but not that common i believe. i need to keep the exact urls from the *original static site* but serve them from the pages module. i don’t want to set up 301 redirects or anything like that. i know that i can use multiple modules together without any custom routing, but i can’t allow the pages module name to remain in the segment. so, i need this type of routing setup.
as i add more modules i’ll just add a route like the one you suggested for every one. i can imagine reading the module directory and building my routes from that, but it is just easier for now to do it by hand.
thanks for the help.
#638 / Sep 24, 2008 8:35am
I have a problem with the latest(4.2) version and Redux Auth 1.4a
Here is what i have:
modules/
users/
config/
redux_auth.php
libraries/
redux_auth.php
controllers/
users.phpusers.php:
class Users extends Controller {
function Users() {
parent::Controller();
$this->load->library('validation');
$this->load->library('email');
$this->load->library('redux_auth');
}
function index() {}
}The result is:
An Error Was Encountered
The configuration file redux_auth.php does not exist.
Am i forced to move redux to application subdirs or am i missing something?
#639 / Sep 24, 2008 10:44am
Redux Auth is a shared library not a module based library, move it (and its config) into the application/directories as per its installation instructions.
Welcome to CI forums.
#640 / Sep 24, 2008 10:52am
Then how should i load module config in module’s libraries ?
Redux does that CI way:
$this->ci =& get_instance();
$this->ci->config->load('redux_auth');What’s whould be ME way?
#641 / Sep 24, 2008 11:05am
modules_instance() returns the instance of the last controller loaded, but you can still use get_instance().
So, in a library you might use:
$ci =& modules_instance(); // or $ci =& get_instance();
$ci->load->config('from_module');Using `load->config` is via ME, while using `config->load` is via CI
#642 / Sep 25, 2008 11:23am
Thank you very much!
#643 / Oct 12, 2008 12:29pm
I’m sorry if this was answered before (I’m sure it was), but is there a way to make it support sub-folders in the controllers to access like this:
Application/modules/test/controllers/admin/welcome.php: localhost/test/admin/welcome
Thanks
#644 / Oct 12, 2008 6:28pm
Hi Armorfist,
Sorry, but controllers in module subdirectories are not supported.
#645 / Jan 01, 2009 1:35pm
Personally, I don’t have any need for subdirectories in the controllers folder at the moment, but is there any plans on making them available?
Edit: I take that back.
What I’d like to do is have something like “sub-modules”.
Folder structure like this
/modules/admin/users/controllers
/modules/admin/users/models
/modules/admin/users/views
..etc
/modules/admin/content/controllers
/modules/calendar/controllers
Access through url via:
http://localhost/admin/users/
http://localhost/admin/content/
http://localhost/calendar/