Jump to content

Okay, Now How Is It Done?


iamz3r0

Recommended Posts

Okay, I'm trying to figure out how I can create a "sidebar" that can be edited on the homepage (or as a separate file and using the "include" function) and be reflected on the entire site.

 

This sidebar contains site information, such as the status of the forums, etc. and it would be difficult to update every page of my site just to change the status.

Link to comment
https://forums.phpfreaks.com/topic/172049-okay-now-how-is-it-done/
Share on other sites

This is what I do..

include(header.php);
include(menu.php);
include(sidebar.php);
CONTENT
include(footer.php);

Just get whatever HTML you're using to display the sidebar, cut it out, put it in sidebar.php for example and link it with php's include where it was supposed to be, problem solved.

I created a new file, with the sidebar information, and using HTML, I added...

 

<!--#include FILE="sidebar.html" -->

 

...where the sidebar would go. It works perfectly as I can see. Any problems with HTML that I should know about when it comes to including files?

<!--#include FILE="sidebar.html" -->

That code is an SSI, or server side include, and has nothing to do with PHP. It functions the same as php's <?php include('sidebar.html'); ?> so i'd recommend using that..

 

But other than that, it looks alright, I just wouldn't want to mix php with SSI with the chance of some problem happening..

Okay, so if I wanted to add something like a 'Welcome [username]' php code, then I'd have to use the php version of the include code?

 

EDIT: Well, the code worked when I was using Dreamweaver, but when it's uploaded (sidebar.html and the page it's included on) it doesn't show up.

Okay, so if I wanted to add something like a 'Welcome [username]' php code, then I'd have to use the php version of the include code?

 

I'm not sure why you're doing it like this is all, If you're using php than stick with php to include all your menus /headers etc. If it's all PHP then apache would have to do less work and create less handles, making the site more optimal. PHP's include() function is faster as it compiles as well, it's no use using SSI's

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.