iamz3r0 Posted August 26, 2009 Share Posted August 26, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/172049-okay-now-how-is-it-done/ Share on other sites More sharing options...
oni-kun Posted August 27, 2009 Share Posted August 27, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/172049-okay-now-how-is-it-done/#findComment-907170 Share on other sites More sharing options...
iamz3r0 Posted August 27, 2009 Author Share Posted August 27, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/172049-okay-now-how-is-it-done/#findComment-907176 Share on other sites More sharing options...
oni-kun Posted August 27, 2009 Share Posted August 27, 2009 <!--#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.. Quote Link to comment https://forums.phpfreaks.com/topic/172049-okay-now-how-is-it-done/#findComment-907179 Share on other sites More sharing options...
iamz3r0 Posted August 27, 2009 Author Share Posted August 27, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/172049-okay-now-how-is-it-done/#findComment-907180 Share on other sites More sharing options...
oni-kun Posted August 27, 2009 Share Posted August 27, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/172049-okay-now-how-is-it-done/#findComment-907182 Share on other sites More sharing options...
iamz3r0 Posted August 27, 2009 Author Share Posted August 27, 2009 Okay, I'm going to build the site up using PHP. It seems you can customize it better. Quote Link to comment https://forums.phpfreaks.com/topic/172049-okay-now-how-is-it-done/#findComment-907188 Share on other sites More sharing options...
oni-kun Posted August 27, 2009 Share Posted August 27, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/172049-okay-now-how-is-it-done/#findComment-907209 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.