Programming Theory
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesProgramming Theory

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old June 18th, 2007, 07:33 AM
matox matox is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Jun 2007
Posts: 4 matox User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 26 m 46 sec
Reputation Power: 0
Includes with .html...

my knowledge of php is limited as of lately but im on a huge crunch with a website i need to make.

its quite large so i want to use php includes but the problem is i cant use .php for the content pages.
so i dont know whats possible out there these days but does anyone have some ideas?

is it possible to make 1 php page with header/menu etc and then call out the content .html page in the menu and then have it load to a certain place on the page??? i remember doing this for photos and short text but not for whole pages.....

any suggestions would greeatly help in my brainstorming!!
thanks

Reply With Quote
  #2  
Old June 18th, 2007, 06:45 PM
lig's Avatar
lig lig is offline
"Forum Nazi"
Codewalkers Demi-God (4500 - 4999 posts)
 
Join Date: Apr 2007
Location: Jacksonville, Fl
Posts: 4,753 lig User rank is Private First Class (20 - 50 Reputation Level)lig User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 Days 8 h 15 m 54 sec
Reputation Power: 7
why can't you use .php as the content page? IIRC you can set the apache config to handle the .html or any other extension to be php.

and maybe what you are looking for is templates.
__________________
life is a game.... Have fun
-----------------------------
http://www.phpwomen.org
strength in unity

PHPCommunity IRC
#phpc on freenode

Reply With Quote
  #3  
Old June 21st, 2007, 12:34 PM
sabian_drummer sabian_drummer is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Jun 2007
Location: Boston
Posts: 25 sabian_drummer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 22 m 27 sec
Reputation Power: 0
not sure why you cant do includes, but try this

if you can't do includes, here is an alternative you could try:
PHP Code:
//file you want to display on your page
$file=location of your file

//open the file
$open=fopen($file,"r");

//read the entire file
$read=fread($open,fileSize($file));

fclose($open);

//print the file contents to your page
echo $read


This should be the same as doing an include.

Reply With Quote
  #4  
Old June 21st, 2007, 05:15 PM
lig's Avatar
lig lig is offline
"Forum Nazi"
Codewalkers Demi-God (4500 - 4999 posts)
 
Join Date: Apr 2007
Location: Jacksonville, Fl
Posts: 4,753 lig User rank is Private First Class (20 - 50 Reputation Level)lig User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 Days 8 h 15 m 54 sec
Reputation Power: 7
depends - that will not include a php file as if it is native to the code - it only echos out the php code.

Reply With Quote
  #5  
Old June 24th, 2007, 11:50 PM
nawlej nawlej is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Dallas, Tx. USA
Posts: 2,008 nawlej User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 7 m 51 sec
Reputation Power: 5
My suggestion would be to use mod_rewrite for this. I recently took over maintenence on a website with tons of legacy content. To get all of it to conform to the new layout, I wrote a PHP "engine" of sorts, and a mod_rewrite rule. Anytime someone called an html file directly, I would take that html, strip out everything between the body tags, and plop it into my layout. Works pretty well.
__________________
Errors have been made. Others will be blamed.
Group Member, Dallas PHP Users Group <b>(DPUG)</b>
--... ...--, Eric

Reply With Quote
  #6  
Old June 25th, 2007, 12:17 PM
matox matox is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Jun 2007
Posts: 4 matox User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 26 m 46 sec
Reputation Power: 0
the content pages need to be .htm for the site editor to work (stupid i know but gotta work by the rules).

i was thinking is it possible to have 1 php page and in the menu when it links to a page have it instead call that page into a certain place on the page?

my php skills are very very rusty, infact i have little idea what to do anymore ;)

thanks for any help!

Reply With Quote
  #7  
Old June 25th, 2007, 12:21 PM
matox matox is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Jun 2007
Posts: 4 matox User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 26 m 46 sec
Reputation Power: 0
Quote:
Originally Posted by nawlej
My suggestion would be to use mod_rewrite for this. I recently took over maintenence on a website with tons of legacy content. To get all of it to conform to the new layout, I wrote a PHP "engine" of sorts, and a mod_rewrite rule. Anytime someone called an html file directly, I would take that html, strip out everything between the body tags, and plop it into my layout. Works pretty well.


how did you go about doing this if i may ask... i dont know much php, would you mind sharing the code?

Reply With Quote
  #8  
Old June 25th, 2007, 09:08 PM
nawlej nawlej is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Dallas, Tx. USA
Posts: 2,008 nawlej User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 7 m 51 sec
Reputation Power: 5
Sure. It is still a bit simplistic, and crude, but here is the code:

First, in my .htaccess file, I did this:

Code:
RewriteEngine On
RewriteRule ^([^/]*\.html) \
index.php?page=$1 [PT]


What the above does is takes all pages with a .html extension, and sends them to index.php. index.php looks like this:

PHP Code:
<?php
//Engine Script to direct all mod_rewrite requests to conform to default page layout.
//Author: Eric
                                                                                
//find the requested file.  If it is HTML, parse between the body tags.  
                                                                                
//Load the templating library
require_once("includes/template.php");
require_once(
"includes/config.php");
                                                                                
$incoming_page $_GET['page'];
                                                                                
if(
file_exists($prefix.$incoming_page)){
        
$file $prefix.$incoming_page;
}else{
        
$file $prefix."main.html";
}
                                                                                
if(
preg_match("/.htm/i",$file)){
        
//parse as an html page
        
$code file_get_contents($file);
        
preg_match("/<body>(.*)<\/body>/s",$code,$matches);
        
$body $matches[1];
}elseif(
preg_match("/.txt/i",$file)){
        
//parse as an html page
        
$body file_get_contents($file);
        
$body "<pre>".$body."</pre>";
}else{
        
//unsupported file format
        
$code file_get_contents($prefix."main.html");
        
preg_match("/<body>(.*)<\/body>/s",$code,$matches);
        
$body $matches[1];
}
$page = new Page("layout.html");
$page->replace_tags(array('content' => $body));
$page->output();
?>


The last couple of lines are my implementation of a templating engine tutorial I came across on this website.

Reply With Quote
  #9  
Old August 20th, 2007, 11:08 PM
sabian_drummer sabian_drummer is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Jun 2007
Location: Boston
Posts: 25 sabian_drummer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 22 m 27 sec
Reputation Power: 0
way to fopen as native code

PHP Code:
//file you want to display on your page
$file=location of your file

//open the file
$open=fopen($file,"r");

//read the entire file
$read=fread($open,fileSize($file));

fclose($open); 


Instead of echoing back the content, you can instruct PHP to evaluate the string as if it were native php code:

PHP Code:
eval($read); 

Last edited by sabian_drummer : August 20th, 2007 at 11:12 PM.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesProgramming Theory > Includes with .html...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek