Solved

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

Posted on 2010-11-14
9
329 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
 
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Workplace bullying has increased with the use of email and social media. Retain evidence of this with email archiving to protect your employees.
If your app took Google’s lash recently, here are the 5 most likely reasons.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now