Computer Science Canada Freat way to manage pages |
Author: | geekhut [ Wed Oct 10, 2007 2:20 pm ] | ||||||||||
Post subject: | Freat way to manage pages | ||||||||||
I know i misspelled "Great" but maybe "FREAT" means something better than great?... to keep things tidy i like to follow a simple template i've been using for the last long time: directory structure / -> /inc -> controller.php (or other standalone included javascript, php files /tpl -> all template files go here (forms, output data) /class -> all classes go here /img ->all images go here /css -> style.css /index.php INDEX.PHP
/inc/controller.php
tpl/viewPosts.inc.php
tpl/createPost.inc.php
tpl/editPost.inc.php
As you can see, controlling functions is very easy using this model and it keeps your source clean and easy to navigate. It is my own twisted way of comprehending the MVC model, except it doesnt make sense to alot of other developers. I put snippets of html (forms) in the tpl directory so i can keep my controller clear for debugging (minimize lines of html in my controller) i didnt include my mysql class because it is quite lengthy but it can be found in the "PHP & MYSQL" tutorial on within this board. the controller function is simple, put the functions you want everyone to be able to do in the $public array. put priviliged functions in the $private array. If some jerk tries to delete a post by guessing post ids ie ()index.php?action=deletePost&pid=201) it will just return him to the home page (or wherever you specify) without deleting the post because he has not initiated a session named private. if you would like to learn more, or if this code sucks, say so.[/b] |
Author: | geekhut [ Wed Oct 10, 2007 2:28 pm ] |
Post subject: | RE:Freat way to manage pages |
I type with only three fingers, im sorry |