/    Sign up×
Community /Pin to ProfileBookmark

File and Design Structure (General)

Hi all, this post is pretty general but I want to use PHP so that’s why it is here.

I have a thorough understanding of PHP and have been developing websites for a few years now, I want to take this one step further and start creating fully dynamic websites from scratch as they would be in industry or fully scaled projects like PHPBB or any PHP CMS system.

At the moment I structure my sites with 1 page that contains the main template for the website, and somewhere inside that where I want the content, I would put a script like so:

[code=php]if($_GET[‘page’]({
include(‘./’ . $_GET[‘page’] . ‘.php’);
}[/code]

Obviously I would put in some error checking and that. Is this the most efficient way of doing it? I read through some articles but most of them said to design a template and include specific files such as sidebar.php and footer.php. The only problem I see with this, is that if I have 20 pages, and I wanted to move the sidebar.php to the bottom, I would need to move the <div> tags on all of the 20 pages.

If you use my way, you only need to edit 1 page and the content doesn’t need to be edited in turn. Any tips and pointers in the right direction?

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@Jeff_MottMay 03.2012 — The approach you're using is actually the same as what the major frameworks. You should stick with what you've been doing.

If you're looking for any further design structure ideas, the article [url=http://symfony.com/doc/current/book/from_flat_php_to_symfony2.html]From Flat PHP to Symfony2[/url] is a nice step by step guide.
Copy linkTweet thisAlerts:
@BradsterauthorMay 03.2012 — Thanks for the link Jeff! I just skim read it and that is exactly what I have been looking for. I had no idea my way of doing things was right, I just thought I was hacking code together with no real structure. Thanks once again.
×

Success!

Help @Bradster spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...