Help - Search - Members - Calendar
Full Version: Coding Question
Zymic Webmaster Forums > Web Design & Development > General Web Design Discussion
XyberForce
I was reading up on something the other day, it was called page auto-change or something like that. But I don't know exactly what it was called. It said that once you update one page on your website, all the others will, too. Now I wish I had that code. Any suggestions? Because in my old site, I had to change the navigation for every single page every time I updated it, and I don't want to have to do that this time.
Ed
Server side inclusion sounds to me what you're looking for.

In php:
CODE
<html>
<head>
<title>Page title</title>
</head>

<body>
<?php echo file_get_contents('navigation.html'); ?>
<div id="content">
Content
</div>
</body>
</html>


If you have php in the navigation, use an include instead:
CODE
<?php include 'navigation.html'; ?>


Couple of links:
http://www.php.net/file-get-contents
http://www.php.net/include

For a finer grain of control you can template your whole site, but if it's just a navigation, stick with the former.
XyberForce
Will the table automatically wrap it if I put the code in there? Btw thanks for helping. =]
Ed
Yup, it'll appear inline with the statement, so providing your HTML is correct and you've not chopped out any tags etc, display won't be altered.
alecrust
Damn you got there before I did Bread tongue.gif

Yeah he is spot on. Make sure your files also have the .php extension.
MrCracker
Yah this is very helpful when designing websites.
XyberForce
Tried it, it works fine. happy.gif
Dan
Yo Bread

What are the benefits of using file_get_contents over a simple include? Especially if get_contents doesn't allow PHP?
Ed
QUOTE(Dan @ Sep 22 2007, 02:27 AM) *
Yo Bread

What are the benefits of using file_get_contents over a simple include? Especially if get_contents doesn't allow PHP?


From a conventional view, it is better to serve static content via a method created to serve static content, there's no requirement to parse the content, so using an include is somewhat frivolous.

I did some benchmarks, results show about a 10% increase in using include over file_get_contents:
http://bread.zymic.com/benchmarks/include_...e_get_contents/

While it's barely significant unless you're doing huge loops; it is technically faster tongue.gif.
XyberForce
Also, why do people hate iFrames so much? They are extremely convenient (my opinion) but, I have to go with the flow, that's why I try to avoid them.
Alex
Mostly because of SEO issues, only very advanced spiders are aware of frames, generally they'll index each page separately, which is very unlike the page the user sees. Whereas SSI builds the page as one entity, which all spiders index as one.

So, iframes mean loss of meta data, and the search engine indexing individual parts of the site separately (meaning when they follow the link they are presented with one part of the website - provided the page works when not in a frame).
Cmain
QUOTE(XyberForce @ Sep 29 2007, 05:31 PM) *
Also, why do people hate iFrames so much? They are extremely convenient (my opinion) but, I have to go with the flow, that's why I try to avoid them.


A CSS approach with an include is much better anyhow. smile.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2012 Invision Power Services, Inc.