I am a new member, I will go in and introduce myself later today in the introductions thread as suggested in the welcome email. Right now I am on a tight deadline and hoping you can help me in the meantime. I need some advice and guidance. I have been a flash designer for years and now I am learning css and html and php. I have a site I am working on, I am about 40% along and I do not want to use frames or open any other windows. I am finding that when I change one thing, I have to change it on every page. For example, the client wants a small blurb about shipping on every page, is there a way I can do this and only have to change it once? Quite a few things like the navigation appear on every page.
From the list of what you are using the thing you need to do to resolve the content you want the same on all pages is to use a PHP include to contain each common part of the page.
That’s basically a separate file with the part of the page in it and an include statement inside every page where you want that code to go. Change that one file and that part of all your pages change all at once.
Thank you! I looked it up and tried it and it works great. I know I didn’t list javascript, but can I do it with that as well? Is it as simple? Thanks!
Congratulations on the move to HTML and CSS. You may feel at times like going back to flash because of browser rendering bugs but hang in there - it’s for the best
You’ve found a great resource to help you find answers when you need them.
HTML -> content
CSS -> presentation
Javascript -> behaviour
It’s best to keep as clear a separation of these 3 as possible. Each can and and should be independent of each other.
I completely agree. When you mentioned Javascript for behavior, what did you mean? Since felgall said to use it sparingly since some people have it turned off.
Under the banner of behavior are things like Events(keyboard, mouse etc.) communication with the server, and animation.
Felgall is saying that the pages shouldn’t rely on javascript to work - they should be perfectly usable without it - just better of more rich experience with it enabled.
The key is being unobtrusive, having the scripts layered on the top of an existing website so that when the functionality is available, it works using that but if scripting is unavailable it’ll just carry on with the minimum level of support (usually consisting of server-side code which is guaranteed to work for everyone). If you want to know more about unobtrusive scripting with JavaScript I highly recommend Jeremy Keith’s book DOM Scripting. as pretty much any core level of functionality which is available at the client-side (JS) can be done at the server-side, you let the server have the default functionality and then can back it up with the more flourished and polished behaviour which JavaScript can offer. An example would be having a contact form, you would use PHP to validate the form fields were input correctly but could have some JavaScript to check before the script is run (less refreshes). Though on a side note, I don’t think JavaScript’s method of including content from separate files is anywhere near as clean as server-side scripting (especially with accessibility in mind) so I would avoid it for such usage.
Javascript should be used for enhancing the user experience, by changing the way a page behaves - but it should not be essential.
If you think of it like a car - the HTML provides the basic shell of the car and the engine and the wheels, enough to make a car that can be driven - the CSS gives it a lick of paint and a nicely shaped body - the Javascript makes the electric windows and cruise control work, all the things that make it a nicer car to drive, but aren’t actually essential.
So for example, you might have pop-up menus that are made to work by CSS, but you can then use Javascript to add effects like having them slide into place, holding them for a moment after you move your mouse away - but don’t make the whole menu reliant on Javascript to work at all. The idea is that someone without Javascript running can access all of your website through, as far as possible, the normal channels - but they might miss out on some of the niceness.
Ok guys, I am back with another question. I don’t know if I should start a new thread or not. How hard is it to load another php page, on click, into the div?