Alternative for include

  • Jaberue
  • Born
  • Born
  • Jaberue
  • Posts: 4

Post 3+ Months Ago

Hi guys,

I am trying to find alternative for php command include in html. Is there anyway to achieve the same thing? Thanks
  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Posts: 854

Post 3+ Months Ago

Not really, however you can use an iframe to load content into. You can also achieve the same effect with javascript or jquery.
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 477

Post 3+ Months Ago

I found something interesting that may interest you. I know I've never used this but I found this article about SSI tags and I did a little test page and works on my server. You would have to check to see if your server allows the tags and your html extensions have to be shtml for it to work, as I understand. http://www.freewebmasterhelp.com/tutorials/ssi

include_test.shtml
HTML Code: [ Select ]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Include Test</title>
</head>
 
<body>
<!--#echo var="DATE_LOCAL"-->
<br />
<!--#include virtual="nav.html"-->
</body>
</html>
 
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Include Test</title>
  6. </head>
  7.  
  8. <body>
  9. <!--#echo var="DATE_LOCAL"-->
  10. <br />
  11. <!--#include virtual="nav.html"-->
  12. </body>
  13. </html>
  14.  


nav.shtml
HTML Code: [ Select ]
This is the nav page
 
  1. This is the nav page
  2.  


here is a link to the test on my server
http://indefinitedesigns.com/include_test.shtml

// Same page only with the html extension instead of the shtml DOES NOT WORK
http://indefinitedesigns.com/include_test.html
  • Zealous
  • Guru
  • Guru
  • User avatar
  • Posts: 1244
  • Loc: Sydney

Post 3+ Months Ago

what about this

Code: [ Select ]
//Var header
$test = "file.html";

//HTML Body

//Inject HTML file

<div align=center> <? readfile($test); ?> </div>
  1. //Var header
  2. $test = "file.html";
  3. //HTML Body
  4. //Inject HTML file
  5. <div align=center> <? readfile($test); ?> </div>


if i remember right it should work for simple stuff but i tried the iframe for a small test script and i found that this was a better way to inject your HTML into your PHP.

Could be a idea?
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

The only options HTML itself has are those mindful mentioned. Realistically, SSI and PHP are doing the same thing, just in different ways.
  • Zealous
  • Guru
  • Guru
  • User avatar
  • Posts: 1244
  • Loc: Sydney

Post 3+ Months Ago

But php gives a better output but i never worked with SSI before.
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 477

Post 3+ Months Ago

I agree with that. I try to stay away from iframes you could also use an object tag as long as you don't need to communicate between the object and parent to get info, the communication works in firefox not in IE

HTML Code: [ Select ]
<object id="page" type="text/html" data="page.htm" width="500" height="600">
  <p>Oops! That didn't work...</p>
</object>
 
  1. <object id="page" type="text/html" data="page.htm" width="500" height="600">
  2.   <p>Oops! That didn't work...</p>
  3. </object>
  4.  


I also have never worked with SSI but when i did a quick search I found that and from what I've looked up it should work on an asp server as well (NOT TESTED). I base my search on including a html file in a html file and not use php, iframes or objects. Since we really don't know why Jaberue wanted to use html instead of php to do an included. all we can do is trow out suggestions
  • Zealous
  • Guru
  • Guru
  • User avatar
  • Posts: 1244
  • Loc: Sydney

Post 3+ Months Ago

Zealous wrote:
what about this

Code: [ Select ]
//Var header
$test = "file.html";

//HTML Body

//Inject HTML file

<div align=center> <? readfile($test); ?> </div>
  1. //Var header
  2. $test = "file.html";
  3. //HTML Body
  4. //Inject HTML file
  5. <div align=center> <? readfile($test); ?> </div>


if i remember right it should work for simple stuff but i tried the iframe for a small test script and i found that this was a better way to inject your HTML into your PHP.

Could be a idea?


This is better then a iFrame!, won't effect the browser half as much as it is just a direct injection via a config file which is your content. simple fix which uses html for the function but still has everything else in HTML.

Post Information

  • Total Posts in this topic: 8 posts
  • Users browsing this forum: No registered users and 26 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.