Welcome Guest, Not a member yet? Register   Sign In
matchbox and that old admin folder question
#1

[eluser]hyperfire[/eluser]
Hi there

Im kinda new to CI, but reading the forum i have found that if i use matchbox along with ci, i could use a structure like this:

modules
-- admin
-----blog (blog administration)
-------controller
---------blog.php {lib etc ....}
-------model
---------blogmodel.php {add edit del ....}
-------view
---------blog_view.php {list all blog posts)
--blog (frontend)
----controller
------blog.php { list blog posts for common user }

What am i doing wrong, because i cannot make it work here, any ideas please?

And why not support those simple folder structures by default?

Thanks
#2

[eluser]Murodese[/eluser]
We use;

modules
--blog
----controller
------admin.php (backend controller)
------blog.php (frontend controller)
----model
------blog_model.php
----views
------backend
--------write.php (example view)
------frontend
--------some-other-view.php
#3

[eluser]hyperfire[/eluser]
Seriously? I need to use that then use a route to get:
example.com/admin/blog
and
example.com/blog
example.com/blog/post/3

and so, what about that configuration on matchbox.php
$config['directories'] = ('modules');

can i add ('modules', 'admin')

and have

admin/blog
blog

Sorry...im trying to get it and found this topic discussed many times without a clear 'theme' for this.
If i need to route, why use matchbox? Just for organization sake?
Thanks
#4

[eluser]Phil Sturgeon[/eluser]
I have a global controller called controllers/admin.php that handles the admin login/logout and other boring functions like that, then each module has a admin.php controller of its own like Murodese above.

The routes you will need to get something like that going is:

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

They could be condensed to one or two regex rules, but kept it like that for clarity.
#5

[eluser]hyperfire[/eluser]
Thanks mate, I´ll try a setup with your code.

This make more sense (using your approach) for a 'modular' system along with matchbox, since I can add 'features' packaged with their own admin files, witch maybe, is a clever idea.

Am I living in the 90´s? No one uses separated folders anymore for backend administration and the main website content or is it really just a matter of organization?
Thanks
#6

[eluser]Phil Sturgeon[/eluser]
I only recently got round to doing it this way. Depends on how modular you want/need your code to be. My code can loose a module any time, and the entire site will then show different content, put a new one in and it shows extra content.

Not every site needs that Undecided
#7

[eluser]hyperfire[/eluser]
Mine needs that too.
On modules folder, i really have only modules that are activated if they are on the modules folder. Otherwise, that 'section' will not show up.
To create the module table on the db, once module is loaded, it performs a check to see if its related table exists, if not, create it.
But when a module is removed, how to erase just the module related tables to get a clean db?
#8

[eluser]opel[/eluser]
To confirm where your routes points to if you were in "domain.com/blog/admin" you would be using the control functions inside blog module, admin controller ?
#9

[eluser]Phil Sturgeon[/eluser]
[quote author="Opel" date="1229552169"]To confirm where your routes points to if you were in "domain.com/blog/admin" you would be using the control functions inside blog module, admin controller ?[/quote]

With the folder structure above, that would be the default URL's for them. With my routes applied it would be admin/blog.

[quote author="hyperfire" date="1227827122"]Mine needs that too.
But when a module is removed, how to erase just the module related tables to get a clean db?[/quote]

I'd be tempted to have install.sql and uninstall.sql or something like that. To remove a module you could run the uninstall.sql after chmod(777) -> unlink(modules/modulename). Could have a main controller to handle that easy enough.




Theme © iAndrew 2016 - Forum software by © MyBB