Click to See Complete Forum and Search --> : DW8 - Template link problem


Beatle_Fan
11-09-2005, 08:48 AM
I have a problem with a template I created. When I view the code, the links to images in the template are correct. They are relative to the site. When the files that use the template are updated, however, they refer to my local computer - using references to my directories where my site is located on my hard drive. So, of course, when I publish the pages they come up with blanks for images. I didn't have this problem with MX - only now that I switched to DW8. My preference for "links relative to" is set to document. Is this the problem? Please explain.

JPnyc
11-09-2005, 09:41 AM
You have to mimic the directory structure that you'll be using on the server, locally on your pc, then be sure to use relative addressing

Beatle_Fan
11-09-2005, 06:38 PM
The directory structure of my site is the same on my hard drive - the problem I have is that when I update the pages from the template, the links have my drive letter and local address - 'file:///C|/path/imagefile'. The template file does not! It has the relative path - /path/imagefile. The template is correct. When it is applied to each page the link changes.

JPnyc
11-09-2005, 08:25 PM
Hmm, you're gonna need someone schooled in DW to help then. I'm not used to anything changing files but me.

Beatle_Fan
11-11-2005, 02:07 PM
I asked this question in the Dreamweaver section and the Administrator answered twice and had the nerve to say I need someone schooled in DW to help. So why did he bother answering? I am calling for your help because you seem like the only person here who does. Here's my original thread

http://www.webdeveloper.com/forum/showthread.php?t=84808

In case that doesn't work...

1) I have a problem with a template I created. When I view the code, the links to images in the template are correct. They are relative to the site. When the files that use the template are updated, however, they refer to my local computer - using references to my directories where my site is located on my hard drive. So, of course, when I publish the pages they come up with blanks for images. I didn't have this problem with MX - only now that I switched to DW8. My preference for "links relative to" is set to document. Is this the problem? Please explain...

2) The problem I have is that when I update the pages from the template, the links have my drive letter and local address - 'file:///C|/path/imagefile'. The template file does not! It has the relative path - /path/imagefile. The template is correct. When it is applied to each page the link changes.

Compguy Pete
11-11-2005, 04:21 PM
1. I need the link to the test page you have online.
2. If you go into manage sites is your site your working on listed there?

Based on what your telling me the template is operating correctly. It has to use a different location for the files as it's in a different directory from the site files.

Your Local directory structure should look something like this.
/Your Root Folder/site files.html
/Your Root Folder/Templates/ <- where you keep your template.dwt file
/Your Root Folder/Images/ <-where you keep your images .jpg & .gif

IF you've just created a template and not set up a site under site manager you could be running into a number of issues.

but in your next post include a link to the page your testing.

kiwibrit
11-12-2005, 05:15 AM
I use DW MX2004, and occasionally used to have this problem, which I would sort by going directly into the coding window of the template, and typing in the correct link.

My own view is that Dreamweaver is fine - but that you should always go into the coding window and tidy up the code before finishing a page.

FWIW, with CSS and php includes, I tend to not use DW templates, now.

Compguy Pete
11-12-2005, 01:16 PM
DW templates are a great time saver! If your not at the point where you are now... I agree not so much that CSS does away with the need for DW templates however the includes weather they be SSI or PHP. However the user in question has not reached this level yet.

The issue comes in for the linking when your...
a. not setting up the site in the site manager window.
b. not putting your images and files in the proper logial order & folders.

HTML is not forgiving of the person creating the page if they don't know why.

Most of the junk code comes in when your dumping text from another app.

Beatle_Fan
11-30-2005, 09:02 AM
Ok, here's what's happening. When I use a template in DW8 all links change to /Template/xxx/xxx.xxx. When I create the template - I use relative links. In other words the images are in images/xxx directory. But when the template is applied, all of the pages that use it change the link to /Template/images/xxx. I can't figure out why or how to keep the links from changing to the Template directory. By the way - I have the files in the proper directories and I NEVER had this problem when I used DW MX. When I switched to DW8 everything that used to work - now doesn't. The very same templates that worked in DW MX now change all of the links to include the Template directory in DW8. What is happening?

JPnyc
11-30-2005, 09:17 AM
Might seem a convoluted solution but perhaps the simplest way would be to try mimicking that directory structure on your server. add a Template directory and put the images folder inside it. Less than ideal certainly, but might resolve the issue.

jr1
12-05-2005, 10:52 AM
Ok, so we've had this issue numerous times with people on our team who refuse to work in the code view.

Assumption 1: You've create a site in Dreamweaver

When you add the images to your page (or template) in design view, you click on Insert > Image and you get the file browser. Click on Sites and Servers and pick the correct site and then pick your image.

The only other solution is to work from the code page and hand code these links. I personally have never had this problem, but when I had to troubleshoot, this is what I managed to figure out.

Good luck

bwalker<?>
03-25-2006, 02:01 PM
Looks like this thread is a little old, but I wanted to put in my 2 cents. I have just encountered the same problem. The template is written with document root paths (../) throughout, but after applying the document root is only used for half the document then suddenly switches to site root paths. One thing to note is that this only occurred on a 3rd level template. The 2nd level template works fine. ?!?! Obviously I know I can hand code this to correct, but that's a lot of links to revise. I don't think this is related to the organization of site files. As I mentioned, it switches from doc to site root half way through. The crazy thing is the images in the first half of the document are located in the same dir as those in the second half. Last thing is that this template was developed with D MX 2004 and it wasn't a problem until D8. I'd love to hear if anyone managed to resolve this.

I've attached a new page generated using the template so you you can see how it changes styles half way through. Maybe you can spot something I missed.
Thanks.

KaiteeFleck
01-08-2008, 07:57 PM
This may not be the same, since half your links were fine, but I had a similar problem where all my links turned to drive mappings because I started editing the page that was created from a template before I saved it.

It seems the act of saving the file updates all the relative paths. If you add any code before saving, it gets all messed up.