Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Replace block of HTML

Posted by TedH (TedH), 26 February 2007
I can replace single element in an html template with no problem. For example:
Code:
<div class="headline">"aaaaa"</div>
can become  
Code:
<div class="headline">"I didn't get an oscar"</div>
using a string.

What I cannot figure out is how to replace an existing block of html. Say like below.
Code:
<!--a-->
<P>Any HTML and text would be here</p>
<!--b-->

with
Code:
<!--a-->
<div>The replacement</div>
<!--b-->


Is there an easy way to do that?

The end result for this is block replacement for my blog script's closed months (I gotta get rid of those forms).

cheers - Ted

Posted by Custard (Custard), 26 February 2007
Hi Ted, hope you are well..

Can you give us a bit more background?

I'm not sure if you are using something like Template Toolkit or have your own template system.

And a bit of code would round it off nicely..

Cheers

B

Posted by TedH (TedH), 26 February 2007
Kinda made up my own
Code:
$_ =~ s/aaaaa/$input{'nf003'}/g;

Where the input replaces the aaaaa

The idea to use the
Code:
<!--a-->
<P>Any HTML and text would be here</p>
<!--b-->

was me just guessing that I needed something above and below the form to mark it out after the page has been made from the template.

Page is used for one month, then the form usage is deactivated at present, but form still there. I figured it's less confusing to remove the form entirely.

Does that make sense?

- Ted

Posted by TedH (TedH), 26 February 2007
I've tried this to see if I can extract the between the tags stuff
Code:
while (<@stuff>) {
print if m#<\!--a-->#i .. m#<\!--b-->#i;
}

While it can print to screen fine after opening the file and reading it into an array, anything else is beyond me.

It's like if the two dots could be read into an array, then it could be replaced with whatever I define.

- Ted

Posted by TedH (TedH), 26 February 2007
Custard, I may be approaching this the wrong way.

Maybe I should try matching the form then replacing it.

There could be 31 HTML files, all of which would need the form replacing. I would have to loop through the folder, read in each file, match the form and replace it for each file.

Does that make sense?

I already replace all the scripts, but with a total rewrite to deactivate them. The HTML files, though, would need to retain everything except the form. I'll give that a go and see what happens.

- Ted

Posted by TedH (TedH), 24 March 2007
Hi Custard, sorry about the delay - been up to my ears in stuff.

I still haven't got anywhere on this, but have put it on hold until for a bit.

How are things your end?

cheers - Ted



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho