Structure is key

People wouldn’t call me especially structured, especially not if you’ve ever taken a look inside my room. But the fact is that I’m very structured. It’s just my personal life that is (mildly speaking) very unstructured.

But this is not going to be a rant about how structured I am but a techical post on how to get away cheaply when structuring sites. I got this idea now that I’m working on Tekvall.se. The main point of the site is to be kind of a portfolio of different design/commercial projects, each sorted into 3 categories - Print, Storytelling and Web.

The biggest issue I have to face with this project is that I have to build a very genereic structure around it, to make it easy for my cst to add new and/or update existing material, without me having to build a complete admin interface aswell.

The way I choose to go about it was to write strict code and setup rules for when and how to translate number into project names.

Let’s take an example, Print. This is fully written and all functions have been completed.
When you first open print.php, this file includes numb-translate.php which basically is to get the ?pid (project id) if there is any set in the header. If there isn’t any set it will automatically include the start page for the prints. However, if it is set, the first thing it will do is to translate the number into text following a preset index and store it into $shownumb. The other thing it will do is to include main-show.php instead of the start page. main-show.php in it’s turn will use $shownumb (the translated ?pid) to determine what to show.

This is where it becomes interesting, since files and folders are named after the translated version of the ?pid other are file standards. So, the actuall file was written in 3 lines using $shownumb to determine filename and folder.
If a file or folder is missing in this script,  nothing but a warning will come up, so there isn’t any chance of my cst’s viewers of getting projects with out all the viable parts there.

The only part where I’ve chosen to let my cst actually edit a core file is the menu. This is simply because if I’ve made this generic aswell, it would pre-determine the links and links might show up that weren’t supposed to be viewable or that lacks the files to be able to browse this.

It’s a pretty simple solution but it keeps it fairly idiot-proof while taking a good benefit from the functions that can be handled by PHP.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*