HighDots Forums  

Dreamweaver - Templates - Image Swaps

Macromedia Dreamweaver Macromedia Dreamweaver Discussions (macromedia.dreamweaver)


Discuss Dreamweaver - Templates - Image Swaps in the Macromedia Dreamweaver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
gwalt
 
Posts: n/a

Default Dreamweaver - Templates - Image Swaps - 07-27-2004 , 02:26 PM






Background:
I have an ASP Dreamweaver page, based on a template, with several javascript
onclick image swaps.

Problem:
When I update the original template page and save, the ASP page is also
updated (like it should), but the javascript onclick image swaps no longer
work. It's like the template update kills the javascript code. I have to
rebuild them and they work.

Any ideas. Thanks in advance for any help.
Mark


Reply With Quote
  #2  
Old   
Murray *TMM*
 
Posts: n/a

Default Re: Dreamweaver - Templates - Image Swaps - 07-27-2004 , 02:40 PM






Let me see your template code, please.

By the way, attachments are discouraged for this and other Macromedia
forums, and to make matters worse, they do not carry forward from the
webforums into the NNTP forums, which is where most of the people who post
answers are visiting. If you want to broadcast your code so that everyone
can see it, the only real way is a) to paste it into a reply (not great if
there is lots of code), or b) to upload it somewhere and post a URI to it.

Be aware that if you paste voluminous quantities of code into a reply, the
code may get truncated when transferring to the NNTP forum. This can be
quite confusing to both poster, and reader. The best bet would be to upload
the page and post a URI.

--
Murray --- ICQ 71997575
Team Macromedia Volunteer for Dreamweaver
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================

"gwalt" <webforumsuser (AT) macromedia (DOT) com> wrote

Quote:
Background:
I have an ASP Dreamweaver page, based on a template, with several
javascript
onclick image swaps.

Problem:
When I update the original template page and save, the ASP page is also
updated (like it should), but the javascript onclick image swaps no longer
work. It's like the template update kills the javascript code. I have to
rebuild them and they work.

Any ideas. Thanks in advance for any help.
Mark




Reply With Quote
  #3  
Old   
gwalt
 
Posts: n/a

Default Re: Dreamweaver - Templates - Image Swaps - 07-27-2004 , 05:49 PM



Thanks Murry. I will post my code soon.

Mark

Reply With Quote
  #4  
Old   
Murray *TMM*
 
Posts: n/a

Default Re: Dreamweaver - Templates - Image Swaps - 07-27-2004 , 05:53 PM



OK - I'll be on the lookout!

--
Murray --- ICQ 71997575
Team Macromedia Volunteer for Dreamweaver
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================

"gwalt" <webforumsuser (AT) macromedia (DOT) com> wrote

Quote:
Thanks Murry. I will post my code soon.

Mark



Reply With Quote
  #5  
Old   
gwalt
 
Posts: n/a

Default Re: Dreamweaver - Templates - Image Swaps - 07-27-2004 , 08:06 PM



Here's a link to my code (text file):

http://www.gulfcoastfsbo.com/gulfcoastfsbo/adpreview.txt

Thanks for your help,
Mark

Reply With Quote
  #6  
Old   
Murray *TMM*
 
Posts: n/a

Default Re: Dreamweaver - Templates - Image Swaps - 07-27-2004 , 09:02 PM



You are dynamically pulling path information from a database for your image
swaps. This is a bad way to do it, in my opinion. Your database should
contain ONLY the name of the image, while the pathing is set in the HTML,
e.g., you have -

onclick="MM_swapImage('photomain','','<%=(rslist.F ields.Item("photo_main").V
alue)%>',1)

and I think you should have -

onclick="MM_swapImage('photomain','','/images/cats/tabbies/<%=(rslist.Fields
..Item("photo_main").Value)%>',1)

as an example. Note that I am using root relative links, because in this
case, the template cannot update your dynamic links as you have noted.

I do it this way on several sites, and it works just fine.

--
Murray --- ICQ 71997575
Team Macromedia Volunteer for Dreamweaver
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================

"gwalt" <webforumsuser (AT) macromedia (DOT) com> wrote

Quote:
Here's a link to my code (text file):

http://www.gulfcoastfsbo.com/gulfcoastfsbo/adpreview.txt

Thanks for your help,
Mark



Reply With Quote
  #7  
Old   
gwalt
 
Posts: n/a

Default Re: Dreamweaver - Templates - Image Swaps - 07-27-2004 , 10:26 PM



Thanks a bunch. I'll give it a try. I'm still a bit confused on two issues
though:

1. Can you explain the "root relative links" issue in more detail? When to
use vs. when not to use. I noticed that your path did not start with the
".../" beginning. Is there a reason for this?

2. So how does the template affect my "non root relative links" if they are
stored in my database. And why are the links only impacted when I update and
save the template file?

Thx,
Mark


Reply With Quote
  #8  
Old   
Murray *TMM*
 
Posts: n/a

Default Re: Dreamweaver - Templates - Image Swaps - 07-28-2004 , 08:02 AM



You're welcome!

See below -

--
Murray --- ICQ 71997575
Team Macromedia Volunteer for Dreamweaver
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================

"gwalt" <webforumsuser (AT) macromedia (DOT) com> wrote

Quote:
Thanks a bunch. I'll give it a try. I'm still a bit confused on two
issues
though:

1. Can you explain the "root relative links" issue in more detail? When
to
use vs. when not to use. I noticed that your path did not start with the
".../" beginning. Is there a reason for this?
Yes - it's a root relative link.

Paths that start with nothing, e.g., <a href="foo.html", or that start with
a reference to the parent folder, e.g., <a href="../foo.html", are document
relative. This means that they describe how to get from the currect
document (wherever it is in the folder hierarchy) to the target document
(wherever it is in the folder hierarchy).

Paths that start with a slash are root relative, e.g., <img
src="/images/foo.gif". This means that they describe how to get from the
root of the site to the target file, no matter where the current page is
located. In this case the root of the site is the reference point, not the
location of the current document.

The use of root relative links means that the link will work (without
maintenance) in any document, in any location in your site.

The use of document relative links means that if the current document is
moved to a new location, the link needs to be adjusted accordingly.
Luckily, DW does this for you automatically on links it can recognize. But
links such as you have, or links embedded in javascript code (as are all the
links in the DW/FW pop-up menus) cannot be recognized by DW, and hence
cannot be maintained. The solution is to not use a link type that needs
this maintenance, i.e., use a root relative link.

So why not use root relative links all the time? Well, you could do this.
They work well, EXCEPT if you are not using temp files to preview in DW,
none of your externally linked files will load when you preview, and none or
your links will work when you preview. Why? Because when the file is
handed to the browser by DW, the browser sees the leading slash and
interprets that as the root of the hard drive, not the root of the site (the
browser doesn't have a clue where the site is). If you ARE using Temp files
to preview (EDIT | Preferences > Preview in Browser), the DW magically
changes all root relative links to document relative links before handing
the file to the browser, so everything works as intended. It does this
because it creates the temp file which is what the browser shows you.

Quote:
2. So how does the template affect my "non root relative links" if they
are
stored in my database. And why are the links only impacted when I update
and
save the template file?
The Template is in the Templates folder, which must be in the root level of
the site. Nothing else should be in the Templates folder. This means that
EVERY link to every file in the template page should look like this -

<a href="../

In other words, it is impossible to get to any other file from the Template
file, without going up one folder level.

Now - when you spawn a child page, and save it in some other location, all
links are adjusted to work from that other location. All links that DW can
*find*, that is. If DW can't find your link, it can't adjust it. And
what's the solution for that? (all together now) ROOT RELATIVE LINKS!

OK - if you store the path to the images in the data field along with the
image filename, and create your links using this information, e.g.,

<img src="<% yourfieldvalue %>"

then you have created a link that a) DW cannot maintain, and b) that is not
ideal for you from a maintenance point of view. Why? Imagine that two
weeks from now, you decide for compelling reasons to move all your image
files to another location within your site. Oops. Now, every image path in
every record in your database has to be adjusted. If, however, you had
created your link like this -

<img src="path/<% filename %>"

then you have only to adjust the single line (or lines) to reflect the new
path.

Geddit?

Quote:
Thx,
Mark




Reply With Quote
  #9  
Old   
gwalt
 
Posts: n/a

Default Re: Dreamweaver - Templates - Image Swaps - 07-28-2004 , 10:00 AM



The light is starting to come on! Thanks a bunch.

One last question and I will let this one be done.

The main reason that I am storing the full path to my images in the database
is that I am dynamically creating a folder for images as each listing is
created (photos uploaded). Now, if I only store the image name I will need to
dynamically build the path when I insert each image in page and call it. Not a
big problem, until I reach my master list page. Here I have a record set that
brings in my listings with photos and displays a preview for selection. I now
need to prefix my image path (/photos/list_number/photo_name.jpg) with the
listing number that's in the recordset, but I can't.

I see two options at this point:

1. Store a short path in the database. Something like -
"/list_number/photo_name". Then I can build a root relative path for each
image to get from the root to the "photos" folder and the remainder of the link
will be in the filename.

2. Store only the file name and figure out a way to completely build the root
relative path on the fly. Don't know how to do yet as I mentioned above.

P.S. I owe you lunch. Thanks so much for your help. Are you paid to do this?

Thx,
Mark


Reply With Quote
  #10  
Old   
gwalt
 
Posts: n/a

Default Re: Dreamweaver - Templates - Image Swaps - 07-28-2004 , 10:12 AM



I fibbed - I have one more question that is bothering me about the template
update issue.

I understand the "root relative" link issue and how when updating the child
files DW does not find my image swap links. However, all of my updates so far
have been minor. I simply made a text change yesterday and the links didn't
work. Can you explain this one?

P.S. Now two lunches.

Thx,
Mark


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.