Welcome Guest, Not a member yet? Register   Sign In
Help on the theory of taking my app multi-year
#1

[eluser]dizzyagain[/eluser]
Greetings,

I have made an internal app for my colleagues and I to manage a database which relates to a project we run.

Now I would like to evolve it into a multi-year app where you can browse through the data which relates to a certain year.

What I am seeking is a bit of advice on the theory of how to do this.

I would like all the tables to remain with an extra field for year - this is so I can do multi year queries. But the important part is in the interface where I'd like it to be possible(for example) to see all 'people' relating to 2009.

My initial thinking was to create sub-folders for years in my controlers folder:

i.e:

Code:
controllers
  2008
    people.php
  2009
    people.php
  2010
    people.php

But then I am duplicating code in each sub folder - having essentially the same controllers just asking for different years results from a model.

Could I instead remap the controllers (all in the root controllers folder) and have the second uri segment be the year to be passed on as a variable? - how then would I access the 'current year' variable so I could easily build the menu and any other links?

Would sessions come into it?

Would jquery come into it?

Any ideas would be greatly appreciated!

Cheers
#2

[eluser]toopay[/eluser]
Why not put it into ACL?
#3

[eluser]dizzyagain[/eluser]
[quote author="toopay" date="1304429237"]Why not put it into ACL?[/quote]

Sorry I don't follow how ACL will help this situation - in fact there is only one admin type required and I already have an authorization system.

Cheers
#4

[eluser]danmontgomery[/eluser]
If you're browsing data relating to a year, one would assume you have dates associated with that data in the DB in some way. I can think of a half dozen different ways to fetch the available date range from the database, and they're all better than forcing yourself to create new controllers every year.

Maybe I'm just not understanding the question, but tasks such as "see all ‘people’ relating to 2009" is exactly what a database is intended for. I see no benefit in trying to create a file structure around this.
#5

[eluser]dizzyagain[/eluser]
[quote author="noctrum" date="1304439219"]If you're browsing data relating to a year, one would assume you have dates associated with that data in the DB in some way. I can think of a half dozen different ways to fetch the available date range from the database, and they're all better than forcing yourself to create new controllers every year.

Maybe I'm just not understanding the question, but tasks such as "see all ‘people’ relating to 2009" is exactly what a database is intended for. I see no benefit in trying to create a file structure around this.[/quote]

Yes I understand how to fetch the appropriate years data from a table - what I am struggling with is a logical way to present the site to a user (and therefore how the controller structure will look).

Allow myself to explain further;

Currently the app is quite simple, in a sidebar menu a user can choose from a menu allowing them to list certain things from different tables (i.e people). As it stands the entire table contains records from only one year.

URI examples:
Code:
myapp.com/people
myapp.com/cars
myapp.com/films

The plan is to extend the database tables by adding a field for year - so that I can make queries to return entries that match a certain year.

Writing the queries I have no problem with but I am a bit stuck on how to get the app design right in the most simple and effective way.

The below example will illustrate two very different ways of 'designing the controllers' (the second using controller remapping) - but I'm not sure if either are the best way!!
Code:
myapp.com/2008/people
myapp.com/2009/people
myapp.com/2010/people

Code:
myapp.com/people/2008
myapp.com/people/2009
myapp.com/people/2010

Perhaps my own visualisation of the user experience is tripping me up; Rather than having a main menu listing all the things (tables), and once you have chosen one, it listing by default all records from the most recent year with a dropbox allowing you to change to years in the past - I would like the user to choose a year off the bat, therefore every item in the main menu will show them the results of the year that they are currently viewing (always while having a prominent option (such as dropdown) to switch to a different year).

An analogy that came to me as I wrote the above sentence was exactly like the way 'localising' an app works with languages - once a user has selected a language they see all the same pages in the menu but with a different language.

I may just be over-thinking all of this - and I apologise if this isn't making sense! I guess this is a very general theoretical app design question... Asking if anyone has some tips on the most sensible way to achieve this.

Cheers
#6

[eluser]Kevv[/eluser]
I'd add a "year" method to your controller to do the filtering, so you'd have URLs like;

mysite.com/people/year/2009/

But being a fan of shorter URLs I'd also check for the presence of a year segment in the controller remap and route to that method directly so I could also have URLs like;

mysite.com/people/2009/

Of course if you think you may want to introduce other criteria down the line you might be better off not using the short version. While I prefer the shorter URL I doubt whether users care (or even notice) how the URL is structured quite so much as developers do Wink




Theme © iAndrew 2016 - Forum software by © MyBB