Dirkmetal Posted October 15, 2009 Share Posted October 15, 2009 My website has a side bar that's on almost every page. It contains links to navigate the site and stuff.Every time I edit this side bar I have to go through and add the changes to very single page, which is annoying, and takes a long time. Does anyone know how I can make it so that if I edit the side bar on one page, it will have the same changes on every other page? Do I need to use PHP for this, or does it work with HTML, or XTML? Is it a script? I don't know anything about javascript or PHP, but I do know how to copy, and paste code. :P Like lets say I have this as a side bar:<!--SIDE BAR START--> <tr> <td valign="top" bgcolor="silver"> <font size="5"><strong>Text</strong></font> <br/><hr> <font size="4"><strong>Text</strong></font> <font size="2"> <br/><br/> Text <br/><a href="URL">Link text</a> <br/><br/> </font> <img src="./pics/spacer.gif" width="1" height="100%"> </td> <!--SIDE BAR END--> If I want to change it, like by adding a link, or fixing a spelling error etc, but not have to go and edit each page manually to add the changes. Link to comment Share on other sites More sharing options...
JoeDaStudd Posted October 15, 2009 Share Posted October 15, 2009 Its easy in php as you can just use require() or include().If you don't have php its possible using javascript, but that would lead to anyone with javascript disabled unable to use the navigation. Anyway this is the php way of doing it.Main page<html> <head></head> <body> <!--SIDE BAR START--> <?php include('nav.htm'); ?> <!--SIDE BAR END--> </body> </html> Navigation page <table> <tr> <td valign="top" bgcolor="silver"> <font size="5"><strong>Text</strong></font> <br/><hr> <font size="4"><strong>Text</strong></font> <font size="2"> <br/><br/> Text <br/><a href="URL">Link text</a> <br/><br/> </font> <img src="./pics/spacer.gif" width="1" height="100%"> </td> </table> I would highly advise you don't use tables in that way though as CSS is a lot better and will allow for much easier coding in the long term. [hide=Drops]Dragon Axe x11Berserker Ring x9Warrior Ring x8SeercullDragon MedDragon Boots x4 - all less then 30 kcGodsword Shard (bandos)Granite Maul x 3Solo only - doesn't include barrows[/hide][hide=Stats][/hide] Link to comment Share on other sites More sharing options...
Nadril Posted October 15, 2009 Share Posted October 15, 2009 Yeah use php like Joe said. Also seconding the non-use of tables, they should only be used for actual tables -- using them for layouts is messy as hell. Use div's (css) instead. Link to comment Share on other sites More sharing options...
Dirkmetal Posted October 15, 2009 Author Share Posted October 15, 2009 Yeah, I'm not to good with CSS's. I need to read up on them some more. Thanks a lot for the help though. :) *edit*It's not loading the "nav.htm". I have already checked and made sure that it's not a typo or something like a capital letter. I'm thinking something is wrong, because when I click "viewscource" in Firefox what i see is: <!--SIDE BAR START--> <?php include("nav.htm"); ?> <!--SIDE BAR END--> Which I know is not right, because your not even supposed to be able to see php code when you view the source.I have even googled your example code, and found a couple of tutorials. I have copy/pasted all the code from those tutorials, and still it won't work. Do I have to compile php or something? Link to comment Share on other sites More sharing options...
Sam Posted October 15, 2009 Share Posted October 15, 2009 Show a screenie of the site and we could help you a little more. 2257AD.TUMBLR.COM Link to comment Share on other sites More sharing options...
Sbrideau Posted October 15, 2009 Share Posted October 15, 2009 Why not simply use an external css file instead? Or maybe I'm misunderstanding something here. Link to comment Share on other sites More sharing options...
Dirkmetal Posted October 15, 2009 Author Share Posted October 15, 2009 Why not simply use an external css file instead? Or maybe I'm misunderstanding something here.CSS's can't add new lines (text, links, images, etc) to the page, can it? I thought it could only modify (color, size, etc) what was already there. *edit*Not even the <?php echo "Text"; ?> is working, do I have to download a PHP plugin? Link to comment Share on other sites More sharing options...
Nadril Posted October 15, 2009 Share Posted October 15, 2009 You need to actually save it as .php not .html. I suggest you read up on some basic tutorials on php. Sure, you could just "copy/paste" but that isn't exactly going to help you in the long run, now is it? We can't hold your hand that much, some of the stuff you'll have to figure out on your own. Link to comment Share on other sites More sharing options...
Sbrideau Posted October 15, 2009 Share Posted October 15, 2009 Why not simply use an external css file instead? Or maybe I'm misunderstanding something here.CSS's can't add new lines (text, links, images, etc) to the page, can it? I thought it could only modify (color, size, etc) what was already there. *edit*Not even the <?php echo "Text"; ?> is working, do I have to download a PHP plugin?I didn't see you wanted to do that, sorry, didn't quite read what was in the code quotes. Link to comment Share on other sites More sharing options...
Dirkmetal Posted October 16, 2009 Author Share Posted October 16, 2009 I have figured it out. I have to down load a plug-in for php to work, but there is no point in me doing that.Also php code is not working online for me, because my web host (freewebs aka webs.com) does not support php unless your a paying member. :( @sbrideau2000: I was just showing that even the most basic of hp was not working for me. Link to comment Share on other sites More sharing options...
Nadril Posted October 16, 2009 Share Posted October 16, 2009 I have figured it out. I have to down load a plug-in for php to work, but there is no point in me doing that.Also php code is not working online for me, because my web host (freewebs aka webs.com) does not support php unless your a paying member. :( @sbrideau2000: I was just showing that even the most basic of hp was not working for me. I'm guessing by plug-in you're probably talking about a CMS like wordpress, right? They generally use PHP for the layout so it is easy to dynamically edit them. Link to comment Share on other sites More sharing options...
sloter Posted October 16, 2009 Share Posted October 16, 2009 If you're just going to have static content and your server it running Apache or lighthttpd you could use SSI(Server Side Includes). Provided your host supports it and with free hosting beggars can't be choosers. With PHP your going to need PHP installed along with some type of web server such as Apache, lighthttpd, IIS, etc. You could do it all on the client side via JavaScript without any server requirements; unfortunately, that means you will need to make sure your user's browser supports JavaScript. Most browsers support JavaScript, however, there are a few that don't such as mobile phones. Link to comment Share on other sites More sharing options...
Dirkmetal Posted October 17, 2009 Author Share Posted October 17, 2009 If you're just going to have static content and your server it running Apache or lighthttpd you could use SSI(Server Side Includes). Provided your host supports it and with free hosting beggars can't be choosers. With PHP your going to need PHP installed along with some type of web server such as Apache, lighthttpd, IIS, etc. You could do it all on the client side via JavaScript without any server requirements; unfortunately, that means you will need to make sure your user's browser supports JavaScript. Most browsers support JavaScript, however, there are a few that don't such as mobile phones.Plus the fact people disable scripts for security. Link to comment Share on other sites More sharing options...
Chrisf Posted October 22, 2009 Share Posted October 22, 2009 I've been wondering this for ages! I could have sworn I did SOMETHING for this... Link to comment Share on other sites More sharing options...
dsavi Posted October 23, 2009 Share Posted October 23, 2009 PHP is not a plugin, it is a preprocessor that runs on webservers. Freewebs is absolutely terrible when it comes to features, as I've found. Link to comment Share on other sites More sharing options...
The Runar Posted October 24, 2009 Share Posted October 24, 2009 It's possible to do this without any PHP/CSS at all:<!--#include file="navbar.html" --> However, for this to work, you must save every single page you use this on as shtml. That basically means changing the extension from html to shtml. Pretty easy. Your navbar code should work with this without any problems. By the way, if you want a good free host, I suggest this one. Much better than Webs. The Runar's (OSRS) DIY blog - most viewed Blogscape blog ever! Contract? /人◕ ‿‿ ◕人\ Link to comment Share on other sites More sharing options...
Dirkmetal Posted October 26, 2009 Author Share Posted October 26, 2009 (edited) It's possible to do this without any PHP/CSS at all:<!--#include file="navbar.html" --> However, for this to work, you must save every single page you use this on as shtml. That basically means changing the extension from html to shtml. Pretty easy. Your navbar code should work with this without any problems.Wait, isn't <!--text--> code for a commenting things out? By the way, if you want a good free host, I suggest this one. Much better than Webs.Looks to good to be true. What's the catch? Do they eat kittens? Fund terrorism? Work for Google? *edit*Does anyone know how to add those icons that are next to the URL in the navigation toolbar, and are on the tabs? Also, stop pronouncing the topic title as " All yee people", the word "Ye" is pronounced as "Th" Edited October 26, 2009 by Dirkmetal Link to comment Share on other sites More sharing options...
The Runar Posted October 26, 2009 Share Posted October 26, 2009 Wait, isn't <!--text--> code for a commenting things out? In this case, nope. Looks to good to be true. What's the catch? Do they eat kittens? Fund terrorism? Work for Google? The only problem I've noticed is that sometimes the control panel works slowly. That's pretty rare though. Does anyone know how to add those icons that are next to the URL in the navigation toolbar, and are on the tabs? They're called favicons. Add this code somewhere on the pages: <link rel="icon" href="/favicon.gif" type="image/gif"> The favicon should be 32x32 pixels. PNG or GIF files can be used (remember to change GIF to PNG in the code if you use that). Upload it in the same folder as the pages. The Runar's (OSRS) DIY blog - most viewed Blogscape blog ever! Contract? /人◕ ‿‿ ◕人\ Link to comment Share on other sites More sharing options...
Sbrideau Posted October 26, 2009 Share Posted October 26, 2009 The one I use is the following, that I find a little easier to remember. <link rel="shortcut icon" href="images/favicon.ico" /> Link to comment Share on other sites More sharing options...
Dirkmetal Posted October 28, 2009 Author Share Posted October 28, 2009 Thanks everyone! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now