Click to See Complete Forum and Search --> : how to handle my sidebar
jamesfoster
07-07-2010, 10:42 AM
I'm new to web development and am in the process of developing a website. I have a sidebar which will be constant on all pages how do go about maknig changes to the side bar content with out have to go to the code for each page
Thanks
ryanbutler
07-07-2010, 10:48 AM
Either use a database driven approach, or use a server-side include.
jamesfoster
07-07-2010, 11:53 AM
Thanks for your reply ryan but like i said im new to web dev so I'll have to go read up on both of these from scratch....which option do you recommend
kelsy476
07-20-2010, 12:45 AM
I'm new to web dev too, but I think Ryan means something like php. If you use the .php extension instead of .html for your pages, you can include a separate document in the code. For example, if you create a .txt file that has the code for your sidebar, for each page you just need to insert the code <? include("sidebar_filepath.txt") ?> where you want the sidebar. That way as long as the location of sidebar_filepath.txt doesn't change, all you have to do is change the content in the .txt file.
Hope this helps!
tirna
07-20-2010, 01:43 AM
or if you don't have access to a server-side scripting language, you could put the html code for your sidebar into a javascript function stored in an external javascript file and then link that external .js file to each page you want the sidebar to appear in and then call the javascript function whenever you want your side-bar to appear.
ryanbutler
07-20-2010, 08:25 AM
Like this:
http://midwestwebdesign.net/tutorials/dynamicmenu/default.aspx
The only problem with includes is they can become tedious to maintain. I would personally go with a database.