19 replies [Last post]
mudrogue
Offline
newbie
Last seen: 11 years 40 weeks ago
Joined: 2008-01-07
Posts: 8
Points: 0

I want to write the css once and the html once for a navigation bar and just import them to several pages on my site with one line of code. That way I only have to update the main file instead of updating all files that contain the navigation bar. How do I do this?

I'm new to css/html comming from a background in c, c++, objective-c, and python, so I know about importing, but I can't find anything online that describes how to do it with html, only css.

Here is the css I would like to import to several pages on my site:

.link-table { position:absolute; top:300; border-collapse:collapse; margin-right:auto; margin-left:auto; }

.link-column
{
padding:0px 0px 0px 0px;
border-style:none;
text-align:center;
width:80;
height:95;
}

Here is the html I would like to be imported and exectued in several pages on my site:

main writing friends movies books art music comment

Aequitas
Aequitas's picture
Offline
Enthusiast
PA
Last seen: 8 years 30 weeks ago
PA
Timezone: GMT-4
Joined: 2007-09-13
Posts: 246
Points: 2

Do you have Adobe

Do you have Adobe Dreamweaver? If so, show the Assets pane (Window>Assets). Library is the last button (looks like a book). Click the "New Library Item" at the bottom of the pane. This will allow you to insert it by dragging the library item into your code while in Dreamweaver.

If you don't have Dreamweaver or don't want to do to this, your only other option (in HTML) is to do a frameset, but don't do this because frames are probably the worse HTML element ever created.

You may be able to find an free/open source content management system that allows you to do this, but I could not give you any guidance on which, sorry.

mudrogue
Offline
newbie
Last seen: 11 years 40 weeks ago
Joined: 2008-01-07
Posts: 8
Points: 0

No, I do not have

No Dreamweaver.

I checked out frames. It seems it's more of a layout oriented solution. I'm just tying to automize importing data into files from other files.

I see how frames can do this, but is this the only way to import html into html files?

rmfred
rmfred's picture
Offline
Elder
Rock Springs, WY
Last seen: 1 year 1 week ago
Rock Springs, WY
Timezone: GMT-6
Joined: 2004-01-31
Posts: 1073
Points: 31

google for "includes" either

google for "includes" either server side or asp or php or search these forums the topic has been covered quite often

Aequitas
Aequitas's picture
Offline
Enthusiast
PA
Last seen: 8 years 30 weeks ago
PA
Timezone: GMT-4
Joined: 2007-09-13
Posts: 246
Points: 2

Boy, for someone who is as

Boy, for someone who is as anal about "following procedure" I'm kind of surprised that you don't even read the OP's request(Drunk. He asked for HTML/CSS solutions, not SERVER SIDE functions.

No, there is no way to import HTML into HTML without the aforementioned server-side languages/functions. However, with your background, it would be fairly easy for you to pick up ASP or PHP (a guess, of course). But, I agree, that is one of the biggest pitfalls of HTML and CSS, not having variables and not being able to import HTML into itself.

mudrogue
Offline
newbie
Last seen: 11 years 40 weeks ago
Joined: 2008-01-07
Posts: 8
Points: 0

I was trying not to have to

I was trying not to have to take on another language to solve this, although I will be interested in looking into them later.

Frames seems to pretty cool becaues they solved part of the problem. But not the whole problem.

I have to start another thread because it's a different issue.

thepineapplehead
thepineapplehead's picture
Offline
Guru
Last seen: 1 year 9 weeks ago
Timezone: GMT+1
Joined: 2004-06-30
Posts: 9668
Points: 801

Yowch. Don't use a table for

Yowch. Don't use a table for that Wink

Verschwindende wrote:
  • CSS doesn't make pies

gary.turner
gary.turner's picture
Offline
Moderator
Dallas
Last seen: 11 hours 49 min ago
Dallas
Timezone: GMT-5
Joined: 2004-06-25
Posts: 9743
Points: 3822

Aequitas wrote:Boy, for

Aequitas wrote:
Boy, for someone who is as anal about "following procedure" I'm kind of surprised that you don't even read the OP's request(Drunk. He asked for HTML/CSS solutions, not SERVER SIDE functions.<snip>

This is a quite common request in these forums, and usually the poster does not know exactly what to ask for. So, we point him to best practice, the include.

A DW solution is neither html nor css—it's an editor hack. Handy, but not at all a good solution. A good solution will be portable (DW is not). What happens if I'm the one who has to edit the menu?

Further, frames are an abomination, having all sorts of issues, not the least of which is browser non-support.

The server side include is portable, both for editing and for serving up. To my knowledge, all web servers in common use support SSI. Syntaxes may vary, RTFM for your server.

Here's an example from O'Reilly's Web Design in a Nutshell,

News


Today's Headlines
...page contents...

All server side scripting languages support an include function. Syntax will depend on the language of choice.

For PHP, substitute <?php include 'navtable.inc'; ?>for the SSI comment syntax.

Note that I use the extension ".inc", but it could be anything. The included bit is a snippet, not a full document.

cheers,

gary

If your web page is as clever as you can make it, it's probably too clever for you to debug or maintain.

Aequitas
Aequitas's picture
Offline
Enthusiast
PA
Last seen: 8 years 30 weeks ago
PA
Timezone: GMT-4
Joined: 2007-09-13
Posts: 246
Points: 2

kk5st wrote:A DW solution is

kk5st wrote:
A DW solution is neither html nor css—it's an editor hack. Handy, but not at all a good solution. A good solution will be portable (DW is not). What happens if I'm the one who has to edit the menu?

Semantics. You need not understand anything but the program ( I explained the entirety of what DW knowledge you need in my post. ), HTML and CSS to perform this. Big difference from having to understand a whole new language. I suppose I agree it is good to mention these things though, I just get ticked off when people are dicks about searching and then they suggest something that is slightly out of the ballpark of what the OP asked.

gary.turner
gary.turner's picture
Offline
Moderator
Dallas
Last seen: 11 hours 49 min ago
Dallas
Timezone: GMT-5
Joined: 2004-06-25
Posts: 9743
Points: 3822

Aequitas wrote:Semantics.

Aequitas wrote:
Semantics. You need not understand anything but the program ( I explained the entirety of what DW knowledge you need in my post. ), HTML and CSS to perform this. Big difference from having to understand a whole new language.

But, I don't have DW, nor will I ever get it. What happens when I'm tasked with adding a new page? How will that menu get included? DW is not a portable solution.

On the other hand, with SSI, the menu snippet is on the server. All I have to do is add a single bit to effectively paste it into my page, or edit the snippet to have it propagated throughout the site. Maintainable by anyone, anywhere, with any editor.

That single bit? That's not a whole new language, it's just one small line, unless you want to learn more. It's a whole lot simpler than trying to learn a complex GUI like DW.

Quote:
I suppose I agree it is good to mention these things though, I just get ticked off when people are dicks about searching and then they suggest something that is slightly out of the ballpark of what the OP asked.

No, the answer was exactly a response to the question. There were two parts to the query: the problem statement, automagically putting a common menu into each page; and how he wanted the problem solved, using html and css.

If the OP knew the how of it, he wouldn't have needed to ask. That he did ask, indicates he doesn't yet have a full understanding of the technologies. Not a problem. The solution does not lie in html and css. It lies in using an include method. And, that is what was offered up.

If someone asks how to strum a G chord using notepad, don't you think a right answer might suggest getting a guitar?

cheers,

gary

If your web page is as clever as you can make it, it's probably too clever for you to debug or maintain.

mudrogue
Offline
newbie
Last seen: 11 years 40 weeks ago
Joined: 2008-01-07
Posts: 8
Points: 0

What happens if I'm the one

I tried this;

#include virtual="navbar.html" and this: php include 'navbar.html';

I get no positive results. The frame allows multiple html inputs to a single html file, but everyone is saying it is not the way to go.

gary.turner
gary.turner's picture
Offline
Moderator
Dallas
Last seen: 11 hours 49 min ago
Dallas
Timezone: GMT-5
Joined: 2004-06-25
Posts: 9743
Points: 3822

First, did you RTFM as

First, did you RTFM as suggested? Do you know if SSI is activated? Or, which server side languages are on your server? You do have to do some homework.

Second, neither of your bits matched what I posted. You must have the syntax correct. Back to RTFM, eh?

Ask your server admin if SSI are turned on, or whether you can use .htaccess to turn them on for your directories.

To test whether you have PHP installed (if you don't already know), create a file named info.php.

In that file, put this single line:
<?php phpinfo(); ?>

Upload to the server's document root directory. Now in your browser, open http://your_domain_name/info.php

If you have PHP installed, lots of stuff about the installation will be sent.

cheers,

gary

If your web page is as clever as you can make it, it's probably too clever for you to debug or maintain.

Aequitas
Aequitas's picture
Offline
Enthusiast
PA
Last seen: 8 years 30 weeks ago
PA
Timezone: GMT-4
Joined: 2007-09-13
Posts: 246
Points: 2

kk5st wrote:But, I don't

kk5st wrote:
But, I don't have DW, nor will I ever get it. What happens when I'm tasked with adding a new page? How will that menu get included? DW is not a portable solution.

Quite the contrary. A Library Item in Dreamweaver is merely a stored snippet of code. If I (the client, hypothetically) needed to include a Library Item, or even modify one, all I need is a plain text editor. Notepad, Wordpad, Notepad ++ will all open DW's .lbi files for editing. Is this not a portable solution?

gary.turner
gary.turner's picture
Offline
Moderator
Dallas
Last seen: 11 hours 49 min ago
Dallas
Timezone: GMT-5
Joined: 2004-06-25
Posts: 9743
Points: 3822

And that .lbi file is stored

And that .lbi file is stored on the server? If it is, how does it get to the served file? If not, how do I put it into my Emacs, Gedit or Vi? Manually paste? Not much advantage there. And if I change the menu outside of DW, how do I propagate those changes to all the documents?

Perhaps there's a way, but I've not heard of it. As far as I know, you'd have application lock-in; and that's not portability.

I am open to learning, though. So tell me, I'm sitting at my Debian box, I've got Emacs fired up, and I'm ready to crank out a new page for the client. The new page will be added to the global navigation menu, which I've downloaded from wherever it was. The altered nav menu must propagate.

With my PHP include, I just upload the new page and the new menu and it's done. How do I do it with DW's drag and drop without using DW?

cheers,

gary

If your web page is as clever as you can make it, it's probably too clever for you to debug or maintain.

mudrogue
Offline
newbie
Last seen: 11 years 40 weeks ago
Joined: 2008-01-07
Posts: 8
Points: 0

I am at the very beginning

I am at the very beginning with css/html. After viewing several online tutorial and pulling books off the Barnes and Noble bookshelf to get specific answer to my questions I swear to God, I never came accross the term: RTFM.

My set up is Firefox browser on Suse. I use Kate to edit my code, they open with Firefox. I don't have time to wait for servers to return to me whether or not my code is working, so I'm doing with a simple browser.

Can I do the import with this set-up?

Phreestyle
Phreestyle's picture
Offline
Enthusiast
Australia
Last seen: 3 years 40 weeks ago
Australia
Timezone: GMT+8
Joined: 2007-05-12
Posts: 235
Points: 6

@mudrogue,

@mudrogue,
RTFM = http://en.wikipedia.org/wiki/RTFM

Waiting for an offsite server is a hassle, so set up your own. If you are running Suse you may, in fact, already have what you need. If not, Google 'lamp'. Here's a link to get you started. http://en.wikipedia.org/wiki/LAMP_%28software_bundle%29

cheers,

Life's a journey. Enjoy the trip.

gary.turner
gary.turner's picture
Offline
Moderator
Dallas
Last seen: 11 hours 49 min ago
Dallas
Timezone: GMT-5
Joined: 2004-06-25
Posts: 9743
Points: 3822

Wow! That Wikipedia article

Wow! That Wikipedia article was way off base on the term's origin. In the US Army, there are manuals, called Field Manuals, for anything and everything a soldier might do. For example FM21-3 dealt with general orders (as my feeble memory serves), and FM22-5 covers how to march and the manual of arms, both long out of date. Yet another, FM 3-34.331 covers the the ins and outs of topographic survey[1] in great detail.

An officer might suggest you read the Field Manual while your sergeant would be more colorful with a "read the effing manual". Soon the abbreviation became a common epithet, RTFM.

As I used it above, once was in respect to the web server and the other related to the programming language. That was exactly the way the term should be used. Another, "Google is your friend" is also a correct response if accompanied by suggested search key words or phrase. The manuals, or web resources supply the knowledge base one needs in order to understand the answers received on forums such as these.

cheers,

gary

[1] Using an older version I bought from the Gov't bookstore about 25 years ago, I managed, with a tape and Brunton pocket transit, to mark the corners of two non contiguous 60 acre properties in a mountain wilderness area with less than a combined 5in closing error. Hubris came in large doses that weekend. Smile

If your web page is as clever as you can make it, it's probably too clever for you to debug or maintain.

Phreestyle
Phreestyle's picture
Offline
Enthusiast
Australia
Last seen: 3 years 40 weeks ago
Australia
Timezone: GMT+8
Joined: 2007-05-12
Posts: 235
Points: 6

Hey Gary,

Hey Gary,
No disrespect or criticism intended.

I was just providing a link to a somewhat arcane piece of terminology. Your use was entirely appropriate.

By-the-by, RTFM is a popular radio station here in my hometown.

regards,

Life's a journey. Enjoy the trip.

gary.turner
gary.turner's picture
Offline
Moderator
Dallas
Last seen: 11 hours 49 min ago
Dallas
Timezone: GMT-5
Joined: 2004-06-25
Posts: 9743
Points: 3822

Naw, my follow-up was

Naw, my follow-up was directed at the silly git that wrote the Wiki article.

We've discussed this often on the forum. The fastest way to destroy a forum or list's usefulness is to worry about hurting somebody's feelings with an RTFM or STFW or Google it, damnit. These are basic, especially on a professionally oriented forum. Breaches of accepted practice should bring a quick and public flogging. This isn't aimed at the OP on this thread, by any means. It is aimed at the idiots who would even think that RTFM is an inappropriate answer, when so often it really is the best answer one could give.

cheers,

gary

If your web page is as clever as you can make it, it's probably too clever for you to debug or maintain.

mudrogue
Offline
newbie
Last seen: 11 years 40 weeks ago
Joined: 2008-01-07
Posts: 8
Points: 0

Thanks for the help

Thanks for the help everyone. uh, I think I got it from here. later.