Forum Moderators: open
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
--
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
--
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. :-)
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]
[edited by: tedster at 9:21 am (utc) on April 6, 2008]
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.
[edited by: Marcia at 5:00 am (utc) on April 6, 2008]
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!
Library item it is! Thanks for your expertise!
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?
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]
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.