Welcome Guest, Not a member yet? Register   Sign In
How to layout my app? Suggestions welcome!
#1

[eluser]Johan André[/eluser]
Hey all!

I'm at the startingpoint of planning and developing a new app.
Before I start off I though it would be a great idea to check with you talented people at this forum.

The app will need to have this structure:

The site has 15 sections (one for each "district") and all sections has it's own range of data (galleries, news, pages, calendars, startpage etc).
The sections need to be accessed with www.mysite.com/{section_name}.
So, if I want to view a gallery in a section I would access: www.mysite.com/{section_name}/gallery/view/1

Also, the administrator will need to access the dashboard of each section by accessing www.mysite.com/{section_name}/admin

Because the controllers for each function (like the gallery) will be exactly the same for each section I want to the develop ONE front-end controller and ONE back-end controller for each function.

How would I lay this one out? Using a (autoloading) library checking the first segment of the url and determine the section from that? Passing the first segment of the url to the controller and determine what section to use?

Suggestions welcome!
#2

[eluser]Stelian Mocanita[/eluser]
I had a similar issue to face in the past and I just went for the routing and uri segmenting and had no issues whatsoever.

For example, routing like:
Code:
$route['(\w{2})/(.*)'] = '$2';
$route['(\w{2})'] = $route['default_controller'];

would make gallery your default controller in a example.com/section1/gallery and you would use as parameters for your calls the first URI segment.

I am recommending this approach as it served me well and keeps your code clean.
#3

[eluser]xwero[/eluser]
Stelian Mocanita you can make it one route
Code:
$route['\w{2}(.*)'] = '$1';
If the url is site.com the route will be empty and the default controller and method will be displayed.

But the solution will suit Johan's needs well because then the section will always be reachable using $this->uri->segment(1) and he will only needs one gallery controller and one admin directory.
#4

[eluser]Stelian Mocanita[/eluser]
Thanks for the fixture, I had a default_controller defined should there wouldn't be a first uri segment.
#5

[eluser]xwero[/eluser]
[quote author="Stelian Mocanita" date="1237906353"]Thanks for the fixture, I had a default_controller defined should there wouldn't be a first uri segment.[/quote]
The second route goes to your default controller when the url has one segment. The common way to handle the missing language segment is to get the language config setting.
#6

[eluser]Stelian Mocanita[/eluser]
I think I misunderstood you or vice-versa Smile

Having for example www.site.com and a default_controller called home. A request toward site.com would lead directly to the home controller, case you verify anyway when mapping the sections so you can return the proper responses (such as 200, 404, etc).

So basically what I was saying, or trying to, is that if there isn't a suitable first uri segment you can take people to a default controller or a 404, or anything you want.




Theme © iAndrew 2016 - Forum software by © MyBB