Welcome Guest, Not a member yet? Register   Sign In
Modular Separation - PHP5 (Modules)

[eluser]Phil Sturgeon[/eluser]
[quote author="ChazUK" date="1273247305"]
I have it working, except for the module routing. Everything has to go in applications/config/routes.php for it to route properly.[/quote]

Modular routing means you do not need to list the module in the route, just the controller. Often they are the same, but in this example I have a controller named "rss" in my "news" module.

Code:
$route['news/(:num)/(:num)/(:any)'] = "news/view/$3";
$route['news/page/(:num)'] = "news/index/$1";

$route['news/rss/all.rss'] = "rss/index";
$route['news/rss/(:any).rss'] = "rss/category/$1";

That making sense?

[quote author="ChazUK" date="1273248945"]Do I have to put each modules default controller in application/config/routes.php?[/quote]

No, just give the controller the same name as the folder.

[eluser]Alface[/eluser]
[quote author="Phil Sturgeon" date="1273249766"]
No, just give the controller the same name as the folder.[/quote]

I use models with the same name as the controllers and also the module.
When I try to create a folder object models of the controller it tries to create the controller. I'm using objects from the DMZ. Any way to solve this problem?

[eluser]Twisted1919[/eluser]
I have this structure :
Code:
/modules/admin/controllers/admin.php
/modules/admin/controllers/site1/site1.php
/modules/admin/controllers/site1/something_else.php
If i try http://localhost/admin/site1 it works but if i do http://localhost/admin/site1/something_else it doesn't, says that page was not found .
Any idea ?

[eluser]theprodigy[/eluser]
Has anyone been able to get this to work in combination with Jamie Rumbelow's MY_Controller and MY_Model?

I have a clean CI installation, MS 1.12, and Jamie's controller and model extensions.

I created a module called 'movies', added controllers, models, and views folders inside of module folder.

I created controller movies.php

I created movies folder inside of views folder, and index.php file inside of that.

When browsing to site.com/movies, I receive the following error:
Quote:Unable to locate the file: ../modules/movies/controllers/movies/index.php

Any feedback would be apreciated.

[eluser]theprodigy[/eluser]
Ok, I haven't done full testing yet, but I am showing some improvement in combining Jamie's MY_Controller with MS.

For anyone else that may want to do this, here is what I've done to get where I'm at.

In MY_Controller, in the _load_view() function (starts around line 137)
Change the line that sets the local $view variable (line 139):
Code:
$view = ($this->view !== null) ? $this->view . '.php' : $this->router->directory . $this->router->class . '/' . $this->router->method . '.php';
to:
Code:
$view = ($this->view !== null) ? $this->view . '.php' : ($this->router->fetch_module()) ? $this->router->class . '/' . $this->router->method . '.php' : $this->router->directory . $this->router->class . '/' . $this->router->method . '.php';

This is only prelim, but it seems to be working at first glance. I have not done anything with MY_Model yet.

[eluser]theprodigy[/eluser]
it appears as though nothing needs to change with MY_Model. It works out of the box.

[eluser]hugle[/eluser]
strange, but I did nothing for MY_Controller to work...

I did MY_Controller with some basics...
also did Public_Controller extending MY_Controller
and Admin_Controller extending MY_Controller..

and everything was working fine

[eluser]theprodigy[/eluser]
using Jamie Rumbelow's MY_Controller, or did you build your own?

[eluser]theprodigy[/eluser]
ok, quick update. I made a small error in the previous update.

To get the full effect of the view loading with Jamie's MY_Controller (view path = class/function.php)

You need to change:
Code:
$view = ($this->view !== null) ? $this->view . '.php' : $this->router->directory . $this->router->class . '/' . $this->router->method . '.php';
to:
Code:
$view = ($this->view !== null) ? $this->view . '.php' : ($this->router->fetch_module()) ? $this->router->fetch_module() . '/' . $this->router->class . '/' . $this->router->method . '.php' : $this->router->directory . $this->router->class . '/' . $this->router->method . '.php';

Change from previous update is: I forgot to add the $this->router->fetch_module() to the $view path assignment. It was in the if statement, but not the assignment. Adding this to the assignment allows the view loading to look in the module path for the view folder, then go to the class/function.php file.

[eluser]Schneider707[/eluser]
Getting the following error:

Code:
Parse error: syntax error, unexpected '=', expecting '(' in /nfs/c04/h04/mnt/***/***/***/html/ci/application/libraries/MY_Router.php  on line 7

Fresh install. MS files located in application/libraries.

Also created:
/modules
/modules/backend
/modules/backend/controller
/modules/backend/controller/backend.php

backend.php --

Code:
<?php

class Backend extends Controller{

    function __construct(){
        parent::__construct();    
    }
    
    function index(){
        echo "test test";
    }

}

Any ideas? I didn't see anything in the previous posts with a problem like this. I'm waiting to get home to try it on my PC to see if its a server/Media Temple issue.




Theme © iAndrew 2016 - Forum software by © MyBB