Forum Moderators: open

Message Too Old, No Replies

Easiest way to change button column site-wide

         

dpd1

12:27 am on Aug 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've always had to deal with this, but it's never been a huge problem, since I wasn't doing sites that were that big. Now I'm doing a site with a daily news section, and the pages are growing fast.

Rather than have empty 'under construction' sections, I add sections as a site grows. Only problem is that the main button controls often have to be changed. I usually use a collection of rollover gifs in a nested frame. Now with all these pages increasing... if I have to change a button collection, it's a huge job to do it site-wide. I'm just curious how some people handle it. I was thinking about going to an iframe for the button columns, but I couldn't get it to work quite right, and I was worried about potential unforeseen problems. I started numbering button graphics, thinking I could just change the graphic and that would change it site-wide. But it still doesn't change the link.

Marshall

12:40 am on Aug 13, 2007 (gmt 0)

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



Use an "inlcude" file.

Marshall

thecoalman

1:46 am on Aug 13, 2007 (gmt 0)

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



If you have php on you server (which you most likely do) the include would look something like this:


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

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

<p>Some content</p>

</body>
</html>

links.php contains the code for your menu, you only need to change it. One thing to note is the file you use the include on has to have the .php extension. It will work with .html extension but you have to set the server to parse .html as .php .

To further that you can use an include at the top and bottom of the document wrapping the unique content.


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

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

<p>unique content</p>

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

</body>
</html>

[edited by: thecoalman at 1:47 am (utc) on Aug. 13, 2007]

dpd1

1:46 am on Aug 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hey, it works... The only way I could get it to work was by making both the visible page and include page as an shtml... Is that normal?

The bad news is that it works fine in a browser from the server, but once the include tag is inserted in a page, it totally destroys how the layout looks in the authoring app. I'm using Dreamweaver MX. Not sure what's happening there.

thecoalman

1:51 am on Aug 13, 2007 (gmt 0)

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



AFAIK you need to set up test server on your computer. Not sure about shtml but you can use something like xampp or easyphp for a quick and easy install for testing enviroment for php.

dpd1

2:08 am on Aug 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for all the help guys... So you think not having something like xampp is what's making the page look crazy in the Dreamweaver? Because on the comp through the browser it looks OK... It's just missing the include element. Which is what I expected. But in the authoring app., I just expected to see a placeholder where the tag should go. Instead, the whole page in trashed. Might be some weird bug.

dpd1

4:51 am on Aug 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks to someone on the Adobe forums, I found the problem... I had left extra unnecessary tags in the included file. That's what was screwing it up. Take all that out except for the part you want to include and it works fine. The content even shows up in design mode.

Now the hard part... Converting the whole site. Ouch.

Thanks,

Dave

rocknbil

7:00 am on Aug 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Now the hard part... Converting the whole site.

Not that hard - if you have access you can do this yourself, if not, have your admin set it up.

The includes are working because the default action is to parse only .shtml files for includes. Edit your server configuration to also parse .html extensions (or, being Dreamweaver, most likely .htm). On an apache server this is a single line of text in httpd.conf

If you bought Dreamweaver in one of the suites, you will also find Homesite on the disk as part of the package, or maybe even DW does this (I hand code, DW exists on my drive as dead disk space so I don't use it much.) Homesite will rip through a directory of 1000 pages in a search and replace in about 20 seconds. Then you're just down to upload time.

If you think it through, this should take you about an hour. :-)

dpd1

10:11 pm on Aug 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'll check and see if I have that Homesite, thanks... I was under the impression that asking the server to parse everything might slow stuff down. Is that a non-issue?

rocknbil

6:27 pm on Aug 14, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It used to be an issue, in fact some webmasters even called it "selfish." But not today.

dpd1

5:11 pm on Aug 15, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK, thanks... I guess since virtually every page will have an include, it doesn't really matter anyway.

thecoalman

11:19 pm on Aug 15, 2007 (gmt 0)

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



You may want to consider the differences between using the php and shtml method. Both will work eqaully as well for your immediate needs but php has practically unlimited potential for future improvements.

Just as a simple quick example for the main navigation the include can be a script that determines which page is requesting it and will remove the anchor tag for that link and highlight it with an arrow. Like a "you are here" feature.

rocknbil

8:20 pm on Aug 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, the issue is the right tool for the job. Sure PHP can do includes. So can perl and ASP. SSI occurs on the server level, PHP, perl, ad ASP are all external scripting languages.

It makes no real sense to use an external scripting language for something as simple as file includes if that is the only task at hand. SSI's have their own subset of functions and can do exactly what you describe in that example - in fact, I use SSI's to import output from external scripts where required. Both will work for that.

dpd1

12:55 am on Aug 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, too late now. I changed the site over the other day. I'm sure php probably does offer a lot more, but this is OK for now. It's already a huge improvement and will save a ton of time. I ended up just parsing html. It seems to work fine. I didn't have a single problem. I might have a slight problem with a footer link set on another site, because I had a different color assigned to the links on the bottom of the page. Not sure how I'll fix that, but it's not a huge deal.