Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Site structure.

  • 16-07-2012 2:08am
    #1
    Registered Users, Registered Users 2 Posts: 3,515 ✭✭✭


    Hey, just out of an interest:
    I always make websites from scratch coding own CMS etc..
    I hate using pre-made stuff so here is the question to those who do same thing.

    Which of these methods you think is better in efficiency wise and which is better in performance,

    Method 1:
    Coding ONE main page, say view.php creating theme, all functions, headers etc.., menu bars and so, yet leaving main body empty, then using isset() for get method to get what user specifically wants, for example:

    .com/view.php?products
    so that tells page to load everything under:
    if(isset($_GET)){

    }

    so technically you have 1 long page with same code re-used again and again but lots of if's and cases.

    Method 2:

    Pre-coding all bars, menus, sql connections, sessions etc.. and saving each to different php file.
    Then creating new file for every page and coding just plain content without any functions ,then use include and require to load all other elements such as menus, bars etc..
    So say:
    menu.php (contains menu bar)
    connect.php (contains sql connection variables)
    session.php (contains all session variables)
    Then you create new page:
    product.php and write up only content yet you include those 3 files?

    Method 3:
    Just copy and paste same code on every page all over and over again?


    Method 4:
    Other? Please specify?


    I am just interested how others do it, right now I am used to mixing both, 1st and 2nd methods.


Comments

  • Registered Users, Registered Users 2 Posts: 8,488 ✭✭✭Goodshape


    Separate your code and try not to repeat yourself, it will be easier to manage in the long run. Your method two is along the right lines.


  • Registered Users, Registered Users 2 Posts: 45 irishd


    Number two is certainly the closest to the mark, but you should really rethink your reasons for not using an existing CMS .. there are very few times where this is not the best use of your time.

    For example, your #2 is much the same as what you would do anyway when creating your own WordPress or Joomla theme but without having to rework the DB & session stuff each time. Spend your time working on the design and usability of your (or your customers?) website, not re-inventing the wheel.


  • Registered Users, Registered Users 2 Posts: 2,040 ✭✭✭Colonel Panic


    Method 4.

    Making something to route URLs as commands which creates controller objects with actions that spit out views generated via a templating engine. Or just use CakePHP or similar MVC framework.

    No need to shoehorn everything into Wordpress or Joomla.


  • Registered Users, Registered Users 2 Posts: 1,023 ✭✭✭[CrimsonGhost]


    Method 4.

    Making something to route URLs as commands which creates controller objects with actions that spit out views generated via a templating engine. Or just use CakePHP or similar MVC framework.

    No need to shoehorn everything into Wordpress or Joomla.

    I'd have to agree with this, if you're dead set on writing your own code over using an existing cms look at setting up your sites with an existing MVC framework. CakePHP, Symphony, Zend Framework etc. Or my personal favourite CodeIgniter. Just pick one, and sit through some basic video tutorials and see what you think.
    Also read up on the mvc pattern so even if you aren't going to use one of these frameworks you'll have an idea on how to structure your code better.


Advertisement