Irish SEO,  Marketing & Webmaster Discussion

 
ThinkGeek - Cool Stuff for Geeks and Technophiles

Help with website - why code like this?

This is a discussion on Help with website - why code like this? within the Coding Help forums, part of the Webmaster Help category; I've been given a site to maintain and after looking through the code it all looks very strange to me. ...


Go Back   Irish SEO, Marketing & Webmaster Discussion > Webmaster Help > Coding Help

Register Forum Rules FAQDonate Members List Calendar Search Today's Posts Mark Forums Read


Notices

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 25-01-2008, 04:43 PM
ButtermilkJack's Avatar
Wannabe Geek
 
Join Date: Feb 2006
Location: Dublin, Ireland
Posts: 267
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
ButtermilkJack will become famous soon enough
Default Help with website - why code like this?

I've been given a site to maintain and after looking through the code it all looks very strange to me. Just wondering if anyone could enlighten me as to the pros of using code like this. I've never seen a site built this way before?

First of all, every page on the site is made up of a basic php template file using only includes. For example...

Quote:
<?
ob_start();
?>

%%HEADER%%
<table border=0 align=center cellpadding=5 width=100% cellspacing=0>
<tr>
<td height=35 class='body'>Office Furniture</td>
</tr>
<tr>
<td class='ref'>%%OFFICEFURNITURE%%</td>
</tr>
</table>
%%FOOTER%%

<?
$template = ob_get_contents();
ob_end_clean();

include "includes/Header.inc.php";
include "includes/OfficeFurniture.inc.php";
include "includes/Menu.inc.php";
include "includes/Footer.inc.php";

echo $template;

?>
So, every page has 2 files. One is the php template, and the other is the php content (or include). I've seen this type of set-up before, but the includes are quite strange themselves (to me anyway) in that each line of code is preceeded with '$TEXT .='. Why would simple html be coded in this way if that's all they want to 'include'?

Quote:
<?
$TEXT = "";
$TEXT .= "<table border=0 cellpadding=2 width=100% cellspacing=0>\n";
$TEXT .= " <tr>\n";
$TEXT .= " <td valign=top width=35%>\n";
...
__________________
Print & Web Design
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 25-01-2008, 10:05 PM
Forbairt's Avatar
respect my AW-THOR-IT-AYY
Recent Blog: Geansai Gorm
 
Join Date: Jun 2007
Location: My Office, Dublin
Posts: 2,101
Nominated 2 Times in 1 Post
Nominated TOTW/F/M Award(s): 1
Forbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enough
Send a message via AIM to Forbairt Send a message via MSN to Forbairt Send a message via Yahoo to Forbairt Send a message via Skype™ to Forbairt
Default

ok ... to me the

Code:
$TEXT = "";
looks a bit strange

Are there any files that get specific things done to the $TEXT ? ... that is returned ?

If not it looks like another case of a self taught php scripter ... (is also guilty of some atrocities in his time ... hopefully a few years+ ago)
__________________
Forbairt Media | Web Design & Development Galway / Dublin, Ireland - coming soon ... ( vague but descriptive isn't it )
Recent Work: Safari Club African Safari Holidays - Malawi Safaris
Other Stuff: FluffyLinkulator Rapid Inclusion Service Tools
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 25-01-2008, 10:47 PM
louie's Avatar
Senior Member
 
Join Date: Jan 2006
Location: Dublin, Ireland
Posts: 2,048
Nominated 5 Times in 3 Posts
Nominated TOTW/F/M Award(s): 1
louie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enough
Send a message via Yahoo to louie Send a message via Skype™ to louie
Default

They look like .tpl template files to me or there is a str_replace function somwhere in the code.
__________________
:. Web Design & Development Web Design Ireland
:. Search Engines Optimization Search Engines Optimization
:. Directory Submission Directory Submission
:. News & Press Release Ireland GiveItSocks.com
:. Used Cars Ireland, Car Parts & Car Audio Cars For Sale, Car Parts & Accessories
:. I Have 2 Find It Directory SEF Directory
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 25-01-2008, 11:15 PM
TheMenace's Avatar
Hardcore Geek
 
Join Date: Nov 2006
Posts: 750
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
TheMenace will become famous soon enough
Send a message via MSN to TheMenace
Default

Looks odd to me.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 28-01-2008, 11:51 AM
ButtermilkJack's Avatar
Wannabe Geek
 
Join Date: Feb 2006
Location: Dublin, Ireland
Posts: 267
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
ButtermilkJack will become famous soon enough
Default

Quote:
Originally Posted by louie View Post
They look like .tpl template files to me or there is a str_replace function somwhere in the code.
Yes, there is reference to str_replace at the bottom of the include file...
Quote:
$template = str_replace("%%OFFICEFURNITURE%%", $TEXT, $template);
The top snippet of code above is the full code for the template file, which is .php, and the include file (also .php) is all html apart from that line above?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6 (permalink)  
Old 28-01-2008, 11:55 AM
louie's Avatar
Senior Member
 
Join Date: Jan 2006
Location: Dublin, Ireland
Posts: 2,048
Nominated 5 Times in 3 Posts
Nominated TOTW/F/M Award(s): 1
louie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enough
Send a message via Yahoo to louie Send a message via Skype™ to louie
Default

so it is a template and is using str_replace to change the text from the buffer
PHP Code:
$template ob_get_contents(); 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7 (permalink)  
Old 28-01-2008, 12:54 PM
ButtermilkJack's Avatar
Wannabe Geek
 
Join Date: Feb 2006
Location: Dublin, Ireland
Posts: 267
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
ButtermilkJack will become famous soon enough
Default

What would be the reason for this? My experience doesn't extend beyong basic html/css so I can't see why use the extra code for a few lines of html. Is there an advantage?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8 (permalink)  
Old 28-01-2008, 12:57 PM
louie's Avatar
Senior Member
 
Join Date: Jan 2006
Location: Dublin, Ireland
Posts: 2,048
Nominated 5 Times in 3 Posts
Nominated TOTW/F/M Award(s): 1
louie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enough
Send a message via Yahoo to louie Send a message via Skype™ to louie
Default

Whoever design that website tried to make use of templates to make it easier to update certain part without editing all the pages, but it is way out of date and it is similar to include or required php function.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9 (permalink)  
Old 28-01-2008, 12:59 PM
Forbairt's Avatar
respect my AW-THOR-IT-AYY
Recent Blog: Geansai Gorm
 
Join Date: Jun 2007
Location: My Office, Dublin
Posts: 2,101
Nominated 2 Times in 1 Post
Nominated TOTW/F/M Award(s): 1
Forbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enoughForbairt will become famous soon enough
Send a message via AIM to Forbairt Send a message via MSN to Forbairt Send a message via Yahoo to Forbairt Send a message via Skype™ to Forbairt
Default

Basically ... you have a header and a footer lets say ...

Now you want to have custom Meta content in your description / keywords ... but you won't know what that is .. until the main body of your content ...

Doing it this way ...

You basically create the whole page .. then go back and do a string replace ...

It means lets say 1 database query .. instead of a database query at the very start ... then potentially another one further down .. having to fix up custom header / footers and so on

That'd be my take on it at any rate

I've rarely put this type of thing into operation I'm unaware of the overheads on a bigger site.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10 (permalink)  
Old 28-01-2008, 01:30 PM
ButtermilkJack's Avatar
Wannabe Geek
 
Join Date: Feb 2006
Location: Dublin, Ireland
Posts: 267
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
ButtermilkJack will become famous soon enough
Default

Yeah, when I initially looked at the code I thought it was some way of pulling content from a db or something. But then I noticed they were using php includes, and that all the content was in an 'includes' folder in the root, so I couldn't understand what seemed like duplication to me.

Anyhow, if it's an outdated practice I won't worry about trying to get to grips with it

Thanks folks!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
code, website

Thread Tools
Display Modes

Posting 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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads

Thread Thread Starter Forum Replies Last Post
How to Avoid the Google Sandbox Cormac Webmaster Articles 26 18-02-2008 05:38 AM
Website now selling with no Shopping Cart? Lottoplus Webmaster Discussion 7 08-01-2008 05:52 PM
New Google Analytics Code... davidbehan Webmaster Discussion 5 02-01-2008 05:18 PM
Need help on Autoresponder Script for my website vckc4ever Coding Help 0 04-07-2007 12:05 PM
recomend IP to Alpha2 and dialing code database Frodo Webmaster Discussion 2 27-01-2007 03:40 PM


Sponsored links

Paid On Results


All times are GMT +1. The time now is 01:17 PM.


Powered by: vBulletin Version 3.7.3, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
Hosted in Ireland by Blacknight - Test your ISP |Irish Hosting Directory| Armchair.ie|Logo by Eden Web Design|Avatars by Afterglow |Latest Blog Entries | VPS HostingAd Management by RedTyger

Search Engine Friendly URLs by vBSEO 3.2.0