Forum Moderators: open

Message Too Old, No Replies

How to Generate Footer Text Message for all pages?

...such as Copyright message - needs to change occasionally

         

pgp566

1:51 pm on Apr 3, 2008 (gmt 0)

10+ Year Member



Sorry if this has been covered before - I cannot find it easily...
I would like to generate a standard footer for all pages that contains a Copyright message, for example. The message needs to be updated occasionally, so I don't want to have to update hundreds of pages each time the message changes.

i.e. I need a standard 'centralised' footer message that I can just link to from each web page.

Perhaps a script would do it, but seems overly complex. Perhaps the message could be embedded in a CSS style? This seems most elegant but I can't find how to do it.

I think this is a simple requirement but has me stumped. Any help greatly appreciated.
Philip
--

mattur

2:32 pm on Apr 3, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi pgp566,

Look at "Server Side Includes" (SSI) - they allow you to include a file in another file(s):

<!--#include virtual="/myfooter.html" -->

pgp566

4:33 pm on Apr 3, 2008 (gmt 0)

10+ Year Member



Hi mattur,

Thanks for very quick reply! I have done a little research on SSI and it seems that I would need to rename all files to have '.shtml' extensions, also that my ISP will need to support '.htaccess'.

It may be possible but I would be happier if there is a client-side way of linking in a piece of standard text from another file. Another possibility would be to 'compile' the include file into all pages. I don't know if it's possible in Dreamweaver. Or I suppose it's possible that an intelligent editor could do a site-wide search and replace on the block of text that constitutes the footer.

If you (or anyone) has experience it would be most welcome.
Many thanks
Philip
--

appi2

5:07 pm on Apr 3, 2008 (gmt 0)

10+ Year Member



If you want to replace text in multiple files in Dreamweaver just use the search and replace tool. You can use a reg exp to match the string your searching for.

You could (but would be silly) also use javascript to replace the footer.

rocknbil

7:43 pm on Apr 5, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



it seems that I would need to rename all files to have '.shtml' extensions, also that my ISP will need to support '.htaccess'.

I'm not sure about the .htaccess comment, but you could have them reconfigure the domain to parse all .html (or .htm) pages for SSI's. It's a simple change in the server configuration file. Then you don't need to change extensions. .shtml was from back in the day when parsing for SSI's was intensive on the server in a shared environment and to separate which files to parse and which ones to serve as static pages. It is really not an issue today.

Hard-coding your change is indeed a solution, but in your example (copyright) you have to do it all again next year. Human error comes into play; what about all those hidden pages in directories, are you sure you haven't overlooked something? :-)

I suppose someone should mention, you can use php includes (or perl, or asp) for the same thing and in the same way, but IMO, these are scripting languages and the equivalent of using a 6 yard bulldozer to remove a clump of grass. Right tool for the job is SSI. :-)

tedster

7:55 pm on Apr 5, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could also use an iframe for the footer content. Then there's also only one file to maintain. I use this approach for legal disclaimers in the footer. I don't want the search engines to see that entire "boilerplate" paragraph duplicated as part of every page - and with an iframe, it isn't.

thecoalman

3:34 am on Apr 6, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



My personal preference is using an include, I like Tedster's idea too but you could use both. Have you considered the other possibilities with includes?

For example here's a simple navigational menu that will deactivate and highlight the link of the page your on using a php include. The require statement includes the file:

In your main page:


<html>
<head>
<title>Your title</title>
</head>
<body>

<?php require($_SERVER['DOCUMENT_ROOT'] . '/includes/nav.php'); ?>

<p>Some content</p>

</body>
</html>

In includes/nav.php :


<?php

$links = array('/index.php' => 'Home',
'/info.php' => 'Information',
'/contact.php' => 'Contact',
'/about.php' => 'About',
);

foreach ($links as $key => $value)
{
if ($key == ($_SERVER['PHP_SELF']))
{

echo '<div class="activelink">' . $value. '</div>';

}
else
{
echo '<div class="livelink"><a href="' . ($key == '/index.php' ? '/' : $key) . '">' . $value . '</a></div>';
}
}
?>

If you never looked at program code this might look a little daunting... however its quite simple. The first part sets up an array of links. If you need to add more simply add them to the array.

The foreach part just loops through the array comparing each entry to the page that requested it, if the request page is matched it will output plain text otherwise its link.

[edited by: tedster at 3:35 am (utc) on April 6, 2008]

tedster

3:39 am on Apr 6, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



One difference between an include and an iframe is this: With an include, the footer content will be part of the content for every url where you use it. As such, it can be indexed and scored by search engines for each of your urls. With an iframe, the footer content is NOT part of every url, just one - its actual address.

[edited by: tedster at 9:21 am (utc) on April 6, 2008]

thecoalman

4:39 am on Apr 6, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yes I understand that Tedster, certainly makes a lot of sense. One of the reasons I frequent this forum is to pick up tips like that. :)

Marcia

4:55 am on Apr 6, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can parse HTML pages for PHP (just use a one-liner in .htaccess) and never have to upate your copyright date ever again. That's why I posted this, figuring I'm probably not the only lazy one around. ;)

The copyright date updates automatically on Jan. 1st each year, sitewide, and you can also automatically show a "Last updated" date when updated pages are uploaded.

[webmasterworld.com...]

It works fine as a footer without being in a table too, just do the formatting for HTML and CSS according to your own page design.

I use PHP includes rather than SSI because the two don't always play well together, and there are other PHP shortcuts that can be used if the pages are enabled for using PHP.

For example here's a simple navigational menu that will deactivate and highlight the link of the page your on using a php include.

Nice! I'd also like to find out how to have the main section link highlighted for all the pages within a /subdirectory/ (section).

[edited by: Marcia at 5:00 am (utc) on April 6, 2008]

pgp566

2:10 pm on Apr 6, 2008 (gmt 0)

10+ Year Member



Very helpful discussion! It's for my own hobby site and thus far I have not got into more advanced programming options like SSI or PHP. These are interesting options and I'm still researching...

In the meantime I tried appi2's idea and I confirm that Dreamweaver search and replace can do the job nicely. It can search and replace whole blocks of HTML, in the current document, in the entire site, selected files in site, or in a specific folder. Also it warns if the result of the substitution generates duff HTML and highlights the problem. Very powerful!

I guess that hardcoding may be somewhat 'inelegant' from a programmer's perspective but for a simpleton like me it's quite reassuring because it's not dependent on remote servers and stuff I potentially don't understand :-) It can update the entire site in a minute or two and only needs doing occasionally.
Thanks!

topr8

2:22 pm on Apr 6, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



can't you also make the footer a 'library' item in dreamweaver?

that way if you change it, all the references to the item update. of course you'd need to reupload the pages to the webserver.

pgp566

10:46 pm on Apr 6, 2008 (gmt 0)

10+ Year Member



topr8, that's exactly the kind of thing I was looking for when I raised the query. Shows how much I know Dreamweaver! I've tried it and it's exactly right. As you say all updated pages will need reloading to the server, but only HTML pages (not images) and only occasionally.

Library item it is! Thanks for your expertise!

penders

11:26 pm on Apr 6, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The copyright date updates automatically on Jan. 1st each year, sitewide, and you can also automatically show a "Last updated" date when updated pages are uploaded.

An aside... General opinion seems to vary on this (on perhaps what 'looks' right), but I've been lead to believe that the date in the copyright notice should be the date of first publication, not simply the current year. Copyright lasts for many years (US and UK). I would have thought it should only be updated on a particular page if the content on that page has significantly changed?

thecoalman

3:39 am on Apr 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Nice! I'd also like to find out how to have the main section link highlighted for all the pages within a /subdirectory/ (section).

Well I'm probably the wrong guy to ask, I know just enough to be dangerous. I only posted the above example because its so simple. I haven't done what you want so I don't have any examples but did do something similar that you may be able to adjust to fit your needs. I'm sure someone that really knows what they are doing could improve on it greatly.

The following code is from an ongoing project and hasn't been fully tested in a live environment and is still undergoing changes. In any event I'm pulling all my data from a mysql database, my navigation table has 4 fields.

link_url , link_text , parent_id , link_order

parent_id is given the same value whether its a main page or sub page. link_order assigns the order the they will appear if they have the same parent ID. For example The main page is assigend the value of one so its first, sub pages will be 1,2,3 etc..

The following will highlight and deactivate the link for what ever page you are viewing and create nested lists, e.g. If you had a main category called "DVD's" who's value for link_order was 1 and a bunch of DVD titles it would look similar to this:

DVD's
-Title1
-title2
-title3

<?php
//mysql connection

// we sort the results based first on parent_id then sort them according to link order so they are in the proper order
$main_links = mysql_query("SELECT * FROM spec_navigation_main ORDER BY parent_id, link_order ASC");

$sql_rows = mysql_num_rows($main_links);

while ($main_row = mysql_fetch_assoc($main_links))
{

if (!$start_ul)
{
echo '<ul class="speclinklist">' . "\n";
$start_ul = true;
$row_num = 0;
$new_ul = $main_row['parent_id'];
}

if ($new_ul !== $main_row['parent_id'])
{
echo '</ul>' . "\n";
echo '<ul class="speclinklist">' . "\n";
}

if ($main_row['link_order'] == 1)
{
if (str_replace('index.php' , '' , $_SERVER['PHP_SELF']) == $main_row['link_url'])
{
echo '<li class="activelink maincat">' . $main_row['link_text'] . '</li>' . "\n" ;
}
else
{
echo '<li class="livelink maincat"><a href="' . $main_row['link_url'] . '" class="leftnavlink">' . $main_row['link_text'] . '</a></li>' . "\n" ;
}
}
else
{
if (str_replace('index.php' , '' , $_SERVER['PHP_SELF']) == $main_row['link_url'])
{
echo '<li class="activelink subcat">' . $main_row['link_text'] . '</li>' . "\n" ;
}
else
{
echo '<li class="livelink subcat"><a href="' . $main_row['link_url'] . '" class="leftnavlink">' . $main_row['link_text'] . '</a></li>' . "\n" ;
}
}

$row_num++;
if ($row_num == $sql_rows)
{
echo '</ul>' . "\n";
}

$new_ul = $main_row['parent_id'];

}
?>

As I said not fully tested and I'm sure there is bugs in it, I believe I've made a few assumptions for this to work properly. First you need a directory structure where index.php is going to be your main page and the link URL for the main page in the table will not have index.php listed. link_url values in your table:

/dvds/
/dvds/title1.php
/dvds/title2.php

[edited by: tedster at 6:26 am (utc) on April 8, 2008]
[edit reason] member request [/edit]

pgp566

10:57 pm on Apr 15, 2008 (gmt 0)

10+ Year Member



"can't you also make the footer a 'library' item in dreamweaver?"

Just want to say again how great this suggestion was from topr8. It also works well for email scripts (anti-spam). Occasionally the email address needs to be updated.

I think one might normally have this kind of thing in a template, however my site consists mainly of image galleries, most of which don't have the email link. Using a library item solves all such problems.

Razzaq

11:42 am on Apr 28, 2008 (gmt 0)

10+ Year Member



Wow...

thank you very much for providing the detail coding for generating the Footer Text Message on each page of the website....

information here has been very helpful for my project/s...

thanks

[edited by: engine at 12:02 pm (utc) on April 28, 2008]
[edit reason] No urls, thanks [/edit]