I'm trying to enhance the printer-friendly print function in book.module. Right now my issue is to remove all the glossary icons from the text. i can remove the glosaary link images ok with a simple replace but it leaves a lot of unseen rubbish in the HTML from the glossary link. Since I want users to be able to use the book text for their own purposes, I'm trying to remove the entire glossary link.
So far i have this
$output = preg_replace('#<a href="/\?q=glossary.+glossary\.gif" /></a>#', '', $output );
and it works except it strips from the start of the first glossary link to the end of the LAST glossary link in the text, instead of removing each instance. How do i get it to stop at the first instance of "glossary\.gif" />". I'm no PHP programmer: can anyone tell me what the pattern needs or how I could code it please?? I WILL give back the code once it is finished.
Comments
Can you provide a sample glossary URL you wish to remove?
I would love to help, but can you provide a sample of what you would like to remove?
Paddy.
http://deburca.org, and http://amadain.net
Paddy.
http://deburca.org
Sorry
<a href="/?q=glossary/5#term50" title="Least Practice: The strategic decision to minimise cost in a discipline of the enterprise by implementing practices sufficient to (a) meet obligations and (b) to make processes work to a standard sufficient that risk (to the organisation and to people in its care) is reduced to some acceptable level."><img src="/modules/glossary/glossary.gif" /></a>It is always the same URL up to the word glossary and always exactly the same .gif for the image, but the text in between varies widely in length and content, and there are multiple instances of these on a page, each for different glossary terms and hence each different contents.
The command I pasted above works cuts once, from the start of the first glossary term to the end of the last one and everything in bewteen.
Think of it as exactly the same problem as wanting to strip out image links that have a caption in them, with widely varying captions.
Can you try something along this line..
The code is rather explicit - and the [^"]+ patterns should match all characters that are not double-quotes.
If this works you can always try reduce the size further.
PS: I have not tested the code.
Paddy.
http://deburca.org, and http://amadain.net
Paddy.
http://deburca.org
Now that...
I have to tell you is REALLY annoying :-D it works beautifully.
Mnay thanks Paddy.
I get it now: run until you hit a quote then stop,then skip over some stuff and run until another quote. Beautiful, thanks i will remember that technique
thanks again
Rob
You are very welcome ))
There is a quote from Alice in Wonderland - when Alice asks the Rabbit for directions, he answers: Start from the beginning, go right to the end, and then stop.
Paddy.
http://deburca.org, and http://amadain.net
Paddy.
http://deburca.org