1.

Solve : Duplicating HTML Code for navigation bar?

Answer»

Hoping to get help from HTML writers:

I don't want to repeat my navigation bar for every page in my site. Can I create it once and then reference it in every other page? Or am I stuck with rewriting the code for every page?You will want to use Frames as referenced here: http://www.velocityreviews.com/forums/t158816-frames-and-a-navigation-bar-and-css.html

Quote

One of the reasons that frames were invented is to enable a navigation bar -
that is - the main page content changes whereas navigation information
remains static and is not duplicated into every html file.
Nooooo....please, do not use frames.

If you don't want to repeat the code on every page, you'll need to use a server-side language like PHP to do it. Quote from: kpac on November 14, 2012, 11:12:51 AM
Nooooo....please, do not use frames.
This made my week
Yeah, frames are not well supported and have been deprecated for many years.

Quote
If you don't want to repeat the code on every page, you'll need to use a server-side language like PHP to do it.
To expand on this:
In PHP, you can use code similar to include($REQUEST['page'] . '.html). If you GO to page.php?page=test, test.html will be displayed.
mod_rewrite can be used to further simplify this to mysite.com/test displaying the test page.
(WARNING: this EXACT code has a lot of problems with it and is not at all secure)
Well we both learned from this then.. LOL ... I learned Programming for the Web back in college in 2000. Interesting to find out that Frames should be avoided now 12 years later with better methods being server side SCRIPTING languages like PHP  Quote from: DaveLembke on November 14, 2012, 08:45:15 PM
Well we both learned from this then.. LOL ... I learned Programming for the Web back in college in 2000. Interesting to find out that Frames should be avoided now 12 years later with better methods being server side scripting languages like PHP 
Oh don't worry, I'm currently doing a web design module in college and they're teaching frames. Luckily I got all my knowledge from 4-5 years experience and self-research.Surprised FRAMES haven't gone the way of GOTO's in programming if they should be avoided in favor of a better method. I guess I have yet to hear the term Spaghetti HTML if using Frames. I started programming on Basic in 1984 and when I learned C++ in college the professor was like "NOOOOOOOOOOOOO .... Ok so you found out that GOTO exists in C++, We dont teach it so NEVER USE IT"...LOL. Someday Frames will go the way of GOTO's and some student will add a frame and the teacher will cry out NOOOOOOOOOO...LOL    Quote from: nanwat on November 13, 2012, 06:55:22 PM
Hoping to get help from HTML writers:

I don't want to repeat my navigation bar for every page in my site. Can I create it once and then reference it in every other page? Or am I stuck with rewriting the code for every page?
I believe you could somewhat streamline the process by creating a template page which contains only your navigation bar.  Then, when you want to add a page, open the template and save it with a different file name and then add the content for that new page. Quote from: DaveLembke on November 17, 2012, 01:31:17 AM
Surprised FRAMES haven't gone the way of GOTO's in programming if they should be avoided in favor of a better method.

Personally, I think that saying "never use X" is premature. Like Goto's, Frames do have their place.

However, that place is nowhere on the modern web. Using Frames will both date your website in addition to simply being rather gross. For example, even when you found frames rather prevalent, you didn't find them on the sites of most tech companies, because even then, they were bad practice. How so? Well, the biggest problem, IMO, with frames, is that they don't work properly with various accessibility tools. Add to this browser dependence (in that different browsers will often interpret the Frameset's differently) pair this with how they go against the fundamental concept of the web as a large collection of individual pages, linked together with hypertext and links and with standalone URLs . The simplicity of the basic concepts are what made the early web both easy to use and incredibly popular. With the more recent focus on web applications (rather than pages) frames take an even further step back, since they are pretty difficult to automate or deal with via client-side script, and considering it's just as easy to use things like CSS floats paired with either a server side include for things like navigation or even an iframe if you really want to keep the content separate, it's no wonder Frames are frowned upon.

Quote
I guess I have yet to hear the term Spaghetti HTML if using Frames.
Because spaghetti HTML would be impossible in concept. HTML is not a programming language, and it does not "execute", and since spaghetti code is used to refer to how things like goto's transfer control all over the place- much like how you don't really know how a single strand of cooked spaghetti weaves it's way through a pile, it's hard to see how control is transferred and where with "spaghetti code". Since there is no execution and no "control structures" in HTML (it being a mark-up, not programming, language, after all) it's impossible to have "spaghetti" HTML.

Quote
I started programming on Basic in 1984 and when I learned C++ in college the professor was like "NOOOOOOOOOOOOO .... Ok so you found out that GOTO exists in C++, We dont teach it so NEVER USE IT"

That is an equally inept opinion, if you ask me. It really drives home the divide between how Programming languages are designed.

There really are two camps: One camp thinks that programmers should be given as many tools as possible, and if they put them together badly, it's their fault. The assumption being that programmers are smart, most of the time. The other camp is the one that thinks the language should be designed so that it is more difficult to make MISTAKES.

They both have their good points. However, something worth noting is that what is and is not a mistake is really up to the language designer.

goto as a keyword is present in C, C++, C#, and a myriad of other languages. These are languages typically designed with the  "give the programmer as many tools as possible" mindset. Other languages, like Java, have a goto keyword, but it is unused- the designers are "protecting" people from it; java is a good example of the latter, since it also lacks Operator Overloading, Extension methods, Lambda's/Delegates, iterator methods, co-routines, and countless other things that have become more and more prevalent as our more popular languages inch their way up to having the same power as Lisp.


Discussion

No Comment Found