Daily Archives: February 14, 2014

Environment page routing

The problem with static pages

All the data about each environment will be stored in a MySQL database.

As we were building and styling the environment page, we hardcoded all this data into the page. This is not an optimal end solution due to the fact that a new file would have to be created for every new environment that is created. And now that we are allowing users to generate their own environments, this would be very resource intensive.

A better solution is to route all the environment page traffic through a different view. The data is then automatically pulled down from the database depending upon which environment is requested. The blank/template environment page is then populated with that data.

The controller

The URL structure for an environment page is like so:

/user/james/env/1

The URL is then split into the 4 components and the username (‘james’) and environment ID (’1′) are extracted.

Then instead of routing the user into the normal file structure, they are routed straight into the environment view. The username and environment ID is then passed into the database to pull down the relevant data.

The same method will be used for the user profiles.