Welcome Guest, Not a member yet? Register   Sign In
Matchbox routes - How to stop repeating the module name in URI?
#1

[eluser]gh0st[/eluser]
I am creating a Modular CMS, I've been able to add a very basic auth layer.

However, I've come across two problems,

1). The module names are repeating in the URI when I need to get to a specific controller

When I make a module "news", my controller looks like this:

Code:
class News extends Controller
{
// init controller stuff goes here ...

function index()
{
   print "Hello, index controller here";
}

function test()
{
   print "Hello, test controller here";
}

function someotherfunction()
{
   print "Hello, " . __FUNCTION__ . " controller here";
}

} // end class

I can't get it to test without repeating the module name in the URI;

ie:
Quote:someuri.com/news/news/test

How do I make it so that I don't repeat the module name in the URI?

I just want it to say:

Quote:someuri.com/news/test
or
someuri.com/news/someotherfunction

I don't want to be repeating the module name for a controller. What is the best way to achieve this?

2). I want it so that when I reference /admin/module_name/controller/ it refers to the specific module I am referencing.

I'm finding this one really difficult to do.

Ideally, what I'd like is:

Code:
someuri.com/admin/news/index/
someuri.com/admin/news/edit/{id}/
someuri.com/admin/news/{any.other.controller}/

I want it so that the above are referencing the proper module, and get access to the correct controller.

A related issue is how to deliver a news module to an end-user (not admin).

In CI-CMS they have an admin folder for every module. Inside the admin folder the controllers, etc extend the Auth Layer and have all the other functionality.

Thanks.
#2

[eluser]Phil Sturgeon[/eluser]
CI-CMS is ridiculously old and really not very good, why are you looking for inspiration there?

PyroCMS uses this for it's admin routes:

Code:
$route['admin/([a-zA-Z_-]+)/(:any)'] = "$1/admin/$2";
$route['admin/(login|logout)'] = "admin/$1";
$route['admin/([a-zA-Z_-]+)'] = "$1/admin/index";

This basically takes admin urls and swaps them around, so each module can have its own admin.php.

As for your first problem, it should work like that out of the box. If you are struggling with bugs. try Modular Separation as so far its been very good to me. Especially the 404 route.
#3

[eluser]gh0st[/eluser]
Okay, thanks for your help Phil; I appreciate it!

The reason why I was looking at CI-CMS was because it seemed to have a lot of modules, but I'll ignore it and see if I can take some ideas from PyroCMS which I downloaded a week ago and the Modular Seperation thing.

Hopefully I can get a resolution on how to sort out the duplication of modules in the URI and make specific module routes go in a specific controller.

Thanks for your help.
#4

[eluser]Phil Sturgeon[/eluser]
Best of luck. I'd download the new v0.9.8-beta2 while you're at it. :-)
#5

[eluser]gh0st[/eluser]
Phil -- I was able to resolve the problem now.

The Modular Seperation library you included in this thread worked better than Matchbox (as it resolved the repeating Module in the URI)

Also, I was able to make admin/module/whatever go to the correct module name too. Which I took from your PyroCMS.

I'm glad as this was a big thing to resolve for this modular CMS I am building.

There I still have an issue.

Where does the themes live if you put stuff out of /www/ root?

In PyroCMS everything lives on /www/ But what happens if you want to move your application and CI stuff outside of root.

This is what I've done with my modular CMS. The only thing in /www/ is index.php and .htaccess and a php.ini file.

The problem is I can't figure out how to reference an admin theme.

In Pyro, you put the admin theme in the application folder.

The solution thus far is to create an /www/assets/themes/admin/stuff...

Either that or I move the 'app' folder into /www/ But I feel this would be a security issue.

What is the best way to resolve this?

Thanks
#6

[eluser]Phil Sturgeon[/eluser]
I have kept everything in wwwroot as currently images, css, js etc can live in the module. I don't care much about getting application out of the web root so have not addressed this.

My admin is not themeable, so it is not in a theme folder.

There is no real security issue as long as your server is passing PHP files correctly there is no problem.
#7

[eluser]gh0st[/eluser]
Oh okay. I'll keep this in mind. Thanks.




Theme © iAndrew 2016 - Forum software by © MyBB