• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 169
  • Last Modified:

Best way to change links on one page and have all pages update without template

We want to add a link on every page that has the menu.  The menu is pretty much just text.  We did not create templates before we started the site.  What is the best way to add this link on every page?
0
TriCountyIT
Asked:
TriCountyIT
  • 5
  • 5
  • 3
  • +1
1 Solution
 
paulp75Commented:
if you are using php, then you can use an includes file
make a file called menu.php and put your menu code in that.
then call it with

<?php include('menu.php'); ?>

or if your not using php, then do a search and replace from the edit menu, you can select it to do the entire site.
0
 
v2MediaCommented:
To elabourate further on paulp75's solution:

First, backup your entire site. Global Find-Replace can make irreversible changes.

Open two files that include the menu. Make your changes to the menu on the first file and save it. Go into code view and hilight the menu code & copy it. Go to the second file in code view and hilight the menu code.  Right click and select Find & Replace.

If the menu code is prepolulated in the "Find" text box, great. If not, hilight the menu code again, copy and pastte into the Find text box. Then you have to past the updated menu code into the Replace text box. Select "Entire Local Site" in the Find in drop list, or "Folder" if the site is not defined.

Click "Replace All". Answer "Yes" to the dialog, "Make changes to other site files... blah".

Watch the list of files that are changes in the Results area. These will be the files that are modified and require syncing with the server.

Now, unless you're using absolute paths in your links, you'll have to rinse and repeat for every directory level in your site. Reason being that image and link paths are different for files in subfolders of the site; so DW is not going to find the exact same code in the "Find" field.

Next site, use an asp or php include. Make everything a whole lot easier to manage.
0
 
Hube02Commented:
If you cannot use includes, either asp or php and you don't want to do the search and replace thing, you can create a library item in DW.

Open the assets panel and choose library (icon looks like a book) right click and choose "New Library Item"
Name it whatever you want and then open and edit it placing your navigation code in it.

To use the library item drag it into the page where you want it. Updating a library item is like updating a template. When you save changes these changes will be copied to all the pages where it is used.
0
Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

 
TriCountyITAuthor Commented:
So I just put the code in that item I want to edit in the library item or do I need the whole page?
0
 
v2MediaCommented:
Hube02's solution involves manually changing existing menu's to library items. Once again, you'd use the find>replace> replace site wide process to do that. Changing one file's menu to a library item will not make that change for all files in the entire site.
0
 
Hube02Commented:
In my version on Dreamweaver when I edit a library item Dreamweaver automatically changes all the files that use that library item.

To answer the question, yes, you should just open the library item and edit that, you should not need to edit each page. Just like a template, Dreamweaver keeps track of the proper path for all the links and updates each page that uses the library item accordingly.

In the page that uses the library item Dreamweaver should add code that looks something like this:

<!-- #BeginLibraryItem "/Library/Untitled.lbi" -->

  YOUR CODE HERE

<!-- #EndLibraryItem -->

You can edit what is between the library tags by hand, but this can break the library items connection and cause problems, but the code also has a yellow highlighting that tells you that it is a library item. As long as you don't edit the code that is highlighted you should not have any problems.


0
 
v2MediaCommented:
That's true Hube02, however you missed the point. Modifying one page to make it's menu a library item will not update the remaining files' menus in the site as a library item as well. In this case you'd have to modify all existing menus to library instances manually; THEN changing the library item will update all files in the site.
0
 
Hube02Commented:
ah, sorry, This is true. v2Media is correct, you'll still need to toch every page or do the search and replace to put the library item into every page. Can still be a tedious process depending on the site. I've had some sites where I actually needed to go in and work on every page as the original developer did not add common items from page to page on the site in exactly the same way.
0
 
TriCountyITAuthor Commented:
The problem is that this isnt a menu.  Its just text in a table that will be linked to a URL.
0
 
v2MediaCommented:
My original response still applies. Follow those steps and you'll have the changes made site-wide.
0
 
TriCountyITAuthor Commented:
I made the changes in the site and the code looks like it worked but the I stll cant link to my external email site.  here is my pages that i want to be changed.  The index works.
index.txt
wmc-about-us.txt
0
 
TriCountyITAuthor Commented:
Sorry I forgot to add that on the bottom where is says staff we want to click on that to link to the external email site to log in.  We want to change that on all pages.  The index works but the others do not.
0
 
v2MediaCommented:
The only reason why <a href="index.html">Staff Area </a> would not work on wmc-about-us is because it is in a subfolder, not the site root. As I mentioned, if you're not using absolute url's you have to rinse and repeat for every subfolder. A link to the index page on a file one directory deep would be:

<a href="../index.html">Staff Area </a>

Two directories deep: <a href="../../index.html">Staff Area </a>

If this email site is external, then why are you using document relative url's for the staff link?
0
 
TriCountyITAuthor Commented:
For the staff url all i did was highlight the text and add a behavior to onclick go to this URL.  I guess I dont understand what you mean by document relative.    Also is it best practive to have all your html pages in the root?
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 5
  • 5
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now