Solved

Are There Any macros that can substitute one block of code for another, in multiple webpages

Posted on 2010-11-14
9
333 Views
Last Modified: 2012-08-13
I need to make the same code change to approximately 75 webpages. There are 2 changes I need to make to each page. Although different, each change involves a "replace this block of code" with a different block of code.

Before hiring a subcontractor to manually do this, I'm wondering if there is any macro software available that can accomplish this? It would need to be fairly simple to set up because, except for a few isolated HTML commands, I really don't know how to program.

I know that there are numerous free as well as commercial macro software programs out there, but I have never used any.

Thanks for your help.
0
Comment
Question by:photoman11
  • 4
  • 4
9 Comments
 
LVL 44

Accepted Solution

by:
scrathcyboy earned 425 total points
ID: 34133144
Can you identify the code block to be replaced by a unique starting tag or word and a unique ending?

And is the code to be replaced available in a separate file?  Does each HTML file get the same code replacement.  IF you can be a bit more specific, we can narrow it down.
0
 
LVL 10

Assisted Solution

by:Tyler Laczko
Tyler Laczko earned 75 total points
ID: 34138250
You can use wordpad, its built into windows, and do a find / replace for the code.
0
 

Author Comment

by:photoman11
ID: 34138709
scrathcyboy,

I have attached the HTML file of a representative page. The page is visible at http://www.best-family-photography-tips.com/EE-test.html.

If you open up the file in an editor, the first block of comments which explains what I want deleted and added, is at line #124. The 2nd block of code is at line #293.

The same code to be replaced is on every page, although not at the same line number as in this page. The blocks of code used as the replacement code, is identical for all pages also.


professionalc…

Thank you. Find and replace would certainly work, but still require a lot of manual intervention. What am hoping to find is some way to automate the process to avoid the manual work.
EE-test.html
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 44

Expert Comment

by:scrathcyboy
ID: 34138871
I looked at the code, and no, I don't see any easy or safe way to automate the 2 replacements -- any macro would depend on your HTML editor, and if you missed one tag, it would foul up all the pages very nicely for you.  Drop me an email if you want help.

I did see one problem though, which you might want to field before you do these replacements.  The INCLUDE file is a SHTML, and I think you will have trouble including a secure HTML page in a non-Secure HTML page.  Does the extension have to be SHTML?  As I recall, both the web server and most browsers will choke on this type of cross-security include.
0
 

Author Comment

by:photoman11
ID: 34142387
scrathcyboy,

Thanks. No problem about the SHTML include - it is my hosting service that insists upon this approach.

Confused about comments that macro seems dangerous, but to drop you an email if want help. Help in a way other than we're discussing?? Please explain.
0
 
LVL 44

Expert Comment

by:scrathcyboy
ID: 34147731
For a macro to work, you have to have a start point and an end point of specific text (or in the case of HTML, code).  Now if that end-point code is missing in a page, or duplicated within the macro area to be replaced, then only part of it will be replaced -- and possibly in all your documents.  Now you have a mess because the code was not completely replaced, so you spend more time fixing it than you would have doing it by hand in the first place.
0
 

Author Comment

by:photoman11
ID: 34151452
Got it. Thank you.

By the way, do you recommend any macros for things in general, which do not require heavy programming abilities?
0
 
LVL 44

Expert Comment

by:scrathcyboy
ID: 34151928
Macros depend on the software you are using.  MS Word continued the tradition of Wordperfect to provide recordable macros for repeated steps in editing word documents.  Making them takes a bit of practice, they are intimidating at first.  But they can be real time savers.

The question of "parsing HTML" code has cropped up here repeatedly on EE, and it is far more fearsome than editing a document.  Browsers are often forgiving -- if you forget to end a form or table with the closing tag, they will render the form or table anyway.  

But in PARSING the HTML -- i.e. going through it and blocking out all the code that exists in a FORM, for example -- if the person put the closing </FORM> tag, then everything is OK.  What happens if they forgot it?  Then instead of parsing the HTML to remove the FORM only, you end up deleting the entire document after the start of the FORM tag, because no end tag was ever found.

That is probably why I have never seen a program to go through HTML code (i.e. parse it) and cut out whole blocks of code and replace with other blocks of code.  You can get macros to change case or search just in a single tag, but the risk of balancing all tags is too great for mass search replace.

So when you do a google search for this -- macro to search replace HTML
almost all you get is discussions of WORD macros and EXCEL macros !!!
TRY IT !!

But neither Word nor Excel are HTML editors.  Therefore you have to find an HTML editor that has macro capability on the HTML code itself (not the finished page) to correctly search and replace the code, and neither do it.  Check your own HTML editor to see if it has Macro features.  IF so, try them.

0
 

Author Comment

by:photoman11
ID: 34152491
thanks for your advice.
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Non-Resizable Pharagraph 2 17
Debugging Html 8 31
Use Mid in Html 6 21
CSS - Centering an image 2 23
When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
This article discusses four methods for overlaying images in a container on a web page
Viewers will learn how to use the Hootsuite Dashboard.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question