Jump to content

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

You ARE asking in a php help section, I assumed you should be using php for that, lol. But yes, PHP is basically the only proper way you can list 'hello username' and list info about the forums etc, in the end it's all dynamic and not static.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.