14 replies [Last post]
moose1184
Offline
newbie
Boston
Last seen: 15 years 35 weeks ago
Boston
Joined: 2006-04-04
Posts: 2
Points: 0

Hello,

I'm working on my first CSS Designed page -- it's three columns, navigation on left, body in center, links on right. The layout is working fine, but I am wondering how I can have the content of a column ripple throughout every page...primarily, as I am making changes to the navigation bar, I want those changes to appear throughout the site without doing it manually. Is there a way to tell the style sheet to copy the content throughout all pages in the site?

Thanks,

Dave

Anonymous
Anonymous's picture
Guru

Linking CSS Column Content

Look up either Server Side Includes or the php include/require command.

thopunk
Offline
Regular
Last seen: 13 years 36 weeks ago
Joined: 2006-04-03
Posts: 21
Points: 0

Linking CSS Column Content

easiest thing to do is a simple php include! work awesomely!

1.) make a file called like "links.php" and put all your links in there.

2.) where you want the links to be, put this code:

<?php include('links.php') ?>

3.) jump for joy.

Anonymous
Anonymous's picture
Guru

Linking CSS Column Content

thopunk wrote:
easiest thing to do is a simple php include! work awesomely!

1.) make a file called like "links.php" and put all your links in there.

2.) where you want the links to be, put this code:

<?php include('links.php') ?>

3.) jump for joy.That doesn't work on a server without php installed though. Smile

thopunk
Offline
Regular
Last seen: 13 years 36 weeks ago
Joined: 2006-04-03
Posts: 21
Points: 0

Linking CSS Column Content

Quote:
That doesn't work on a server without php installed though. Smile

True, but I assume he has php on his server, since it is 2006. Smile

Anonymous
Anonymous's picture
Guru

Linking CSS Column Content

thopunk wrote:
Quote:
That doesn't work on a server without php installed though. Smile

True, but I assume he has php on his server, since it is 2006. SmileThat would be smashing, wouldn't it? Unfortunately,...

DisinfectedBarfbag
DisinfectedBarfbag's picture
Offline
Enthusiast
Kent, UK
Last seen: 1 year 32 weeks ago
Kent, UK
Timezone: GMT+1
Joined: 2005-08-06
Posts: 411
Points: 1

Linking CSS Column Content

thopunk wrote:

1.) make a file called like "links.php" and put all your links in there.

2.) where you want the links to be, put this code:

<?php include('links.php') ?>

Almost Wink Instead of using <?php include('links.php') ?> use <?php require('links.php'); ?> That way it only loads once, include loads it fresh for every new page visited.

moose1184
Offline
newbie
Boston
Last seen: 15 years 35 weeks ago
Boston
Joined: 2006-04-04
Posts: 2
Points: 0

Thanks

Okay, I'm going to try the PHP thing -- I'm a student and right now only using my school's server for testing before I buy a domain...will find out soon enough...thanks for all the replies!

Dave

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 6 years 47 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

Linking CSS Column Content

DisinfectedBarfbag wrote:
Almost Wink Instead of using <?php include('links.php') ?> use <?php require('links.php'); ?> That way it only loads once, include loads it fresh for every new page visited.

I thought that that require and include were meant to function identically with one important distinction being that include is a non critical function producing a warning on failure, but require is a critical one and failure to process produces a 'fatal error' and halts script execution.

Hugo.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

Anonymous
Anonymous's picture
Guru

Linking CSS Column Content

DisinfectedBarfbag wrote:
Almost Wink Instead of using <?php include('links.php') ?> use <?php require('links.php'); ?> That way it only loads once, include loads it fresh for every new page visited.

That's news to me. The only difference I know between the two is using require() if the file does not exist, you will get a fatal error but using include() if the file does not exist, you will get a warning and the next line of code will execute. Otherwise they are identical. There is an include_once() and require_once() but they just avoid the include from loading more than once.

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 6 years 47 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

Linking CSS Column Content

Echo Echo Echo

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

DisinfectedBarfbag
DisinfectedBarfbag's picture
Offline
Enthusiast
Kent, UK
Last seen: 1 year 32 weeks ago
Kent, UK
Timezone: GMT+1
Joined: 2005-08-06
Posts: 411
Points: 1

Linking CSS Column Content

From http://www.tizag.com/phpT/require.php

Quote:
The echo statement was not executed because our script execution died after the require function returned a fatal error! We recommend that you use require instead of include because your scripts should not be executing if necessary files are missing or misnamed.

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 6 years 47 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

Linking CSS Column Content

That quote does not explain the " reloads it every page" the quote is somewhat confusing I would have said, why would you want a script to fail a whole page all the time if you included a nav menu I would rather the menu failed to appear but at least the rest of the content displayed and other links allowed me to exit through breadcrumbs or some other means than the whole page just fail with an error message.

Of course they are times where require should be used but it's more likely on calls to DB functions.

I like the tizag site and use it for reference sometimes but i think that page is somewhat oversimplified. Are we never to use 'include' then? is it redundent?

Hugo.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

DisinfectedBarfbag
DisinfectedBarfbag's picture
Offline
Enthusiast
Kent, UK
Last seen: 1 year 32 weeks ago
Kent, UK
Timezone: GMT+1
Joined: 2005-08-06
Posts: 411
Points: 1

Linking CSS Column Content

Hugo wrote:
That quote does not explain the " reloads it every page" the quote is somewhat confusing I would have said, why would you want a script to fail a whole page all the time if you included a nav menu I would rather the menu failed to appear but at least the rest of the content displayed and other links allowed me to exit through breadcrumbs or some other means than the whole page just fail with an error message.

Ok I admit I got that a bit wrong, it must have been after reading loads of other pages at the time. You mention other ways of navigating the site with alternative methods included, but what if there isn't? Not all sites have these so that wouldn't apply. And surely your not advocating uploading a site that 'Does Not Validate' Wink

Quote:
Of course they are times where require should be used but it's more likely on calls to DB functions.
You have a point.

Quote:
I like the tizag site and use it for reference sometimes but i think that page is somewhat oversimplified. Are we never to use 'include' then? is it redundent?

Hugo.

Well with my limited knowledge I thought that would be a better option than include. But what do I know :?: :?

EDIT
Just found this which gives a slightly different view on this also. http://builder.com.com/5100-31-5077715.html

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 6 years 47 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

Linking CSS Column Content

Quote:
And surely your not advocating uploading a site that 'Does Not Validate
:?

The moral of the story is really that each function needs to be understood exactly and the correct one for the purpose used, each has it's place in the grand scheme of things.

The builder.com link does lend a more detailed explanation , in particular the variable scope aspect of the two functions which seems to be seldom explained and could be a critical aspect, however I am still slightly bemused at the advice that it's better to use 'require' for static calls such as footer elements, so the author would rather his entire page kicked over for the sake of a paragraph or two of static text in a footer rather than a few lines of an error message, that one needs to be explained to me.

I am however not at a level where I am going to argue with him, I shall continue to use 'include' for things like simple static calls until such time as it's demonstrated that it's not wise.

Hugo.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me