Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > How should I script my site?

How should I script my site?
Thread Tools
genevish
Mac Enthusiast
Join Date: Jan 1999
Location: Marietta, GA, USA
Status: Offline
Reply With Quote
Oct 1, 2004, 09:57 PM
 
I made a website for my wife's Mothers group some time ago, and just got them to switch it to a paid host (PHPWebHosting). Now I'm wanting to make the site elements that are standard across all pages into PHP include file(s). In the site (linked below), there are three div sections. The right section does not change, nor does the left, except for the color of the link currently selected, and the bottom of the center section does not change.

How would you structure it? A single index page that dynamically loads different center content based on GET variables? Different index pages that load identical include sections for the right and left sections, and just have the center content laid out? Or some other approach?

The site is at http://www.woodstockmm.com/.

Thanks

-Scott

P.S. The site is non-profit and has no ads, so I'm not ad-whoring...

P.P.S Any other feedback is welcome too!
Scott Genevish
scott AT genevish DOT org
     
Arkham_c
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status: Offline
Reply With Quote
Oct 6, 2004, 08:24 AM
 
Originally posted by genevish:
How would you structure it? A single index page that dynamically loads different center content based on GET variables? Different index pages that load identical include sections for the right and left sections, and just have the center content laid out? Or some other approach?
Unless you have a specific reason to do so, I don't personally like the single index concept -- you end up with a giant lookup table somewhere in your code and there's no reason for that. Just make the reusable components into includes and include them on the pages. It could be as complete as:

[php]
<?php include("page_header.php") ?>

Data custom to this page

<?php include("page_footer.php") ?>
[/php]

You could have sub-includes if this model doesn't work, but I don't think that results in too much redundant code per page.

PS. I grew up in Marietta, GA, and my dad still lives there.
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
     
madmacgames
Grizzled Veteran
Join Date: Oct 2003
Status: Offline
Reply With Quote
Oct 6, 2004, 02:13 PM
 
Originally posted by Arkham_c:
Unless you have a specific reason to do so, I don't personally like the single index concept -- you end up with a giant lookup table somewhere in your code and there's no reason for that.
not if the page is passed in the URL. there is no need for a lookup table in either case.

Really, my advise is do it the way that makes the most sense to you. You are basically either creating a page that contains the common elements and including the main content, or creating the main content and including the common elements. Just 2 ways of doing basically the same thing and with a simple site you'll have about the same number of files (either one main page with x number of main content files -or- x number of main pages with a few include files).

So... just do it the way that makes sense to you
The only thing necessary for evil to flourish is for good men to do nothing
- Edmund Burke
     
Arkham_c
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status: Offline
Reply With Quote
Oct 6, 2004, 09:32 PM
 
Originally posted by madmacgames:
not if the page is passed in the URL. there is no need for a lookup table in either case.
You gotta be careful with that though. You can't just blindly include whatever is passed in the query string, because that's a security risk. Hence the lookup table. The alternate solution is to only allow includes from a specific directory.
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
     
madmacgames
Grizzled Veteran
Join Date: Oct 2003
Status: Offline
Reply With Quote
Oct 6, 2004, 11:04 PM
 
Originally posted by Arkham_c:
You gotta be careful with that though. You can't just blindly include whatever is passed in the query string, because that's a security risk. Hence the lookup table. The alternate solution is to only allow includes from a specific directory.
well generally the "main content" includes would all be in the same directory or follow the same directory structure, so you only have to pass the file name or main content page's directory and then avoiding false main content sections can be avoided by something as simple as checking if the file (or directory) exists and if not, then just redirect to the main index page. Still no need for a lookup if you take a few simple but easy steps.
The only thing necessary for evil to flourish is for good men to do nothing
- Edmund Burke
     
genevish  (op)
Mac Enthusiast
Join Date: Jan 1999
Location: Marietta, GA, USA
Status: Offline
Reply With Quote
Oct 11, 2004, 07:57 PM
 
Originally posted by Arkham_c:
Unless you have a specific reason to do so, I don't personally like the single index concept -- you end up with a giant lookup table somewhere in your code and there's no reason for that. Just make the reusable components into includes and include them on the pages. It could be as complete as:

[php]
<?php include("page_header.php") ?>

Data custom to this page

<?php include("page_footer.php") ?>
[/php]

You could have sub-includes if this model doesn't work, but I don't think that results in too much redundant code per page.

PS. I grew up in Marietta, GA, and my dad still lives there.
Since my own site uses this method I went ahead and went with it. I just wasn't sure if there was a better way.

Thanks for the replies.

-Scott
Scott Genevish
scott AT genevish DOT org
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 10:24 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,