PEAK XOOPS - Replace ampersand with XHTML equivalent in englishin japanese

Replace ampersand with XHTML equivalent

  • You cannot open a new topic into this forum
  • Guests cannot post into this forum
Previous post - Next post | Parent - Children.1 | Posted on 2006/10/14 23:27
JMorris  企霹始   Posts: 4
Is there a safe way of using str_replace or preg_replace to replace the "&" (ampersand) so commonly used in peoples news feed titles with the XHTML compliant &a mp; [space added to prevent parsing]?

Thanks!

James
Votes:15 Average:1.33
Previous post - Next post | Parent - Children.1 | Posted on 2006/10/15 3:52
GIJOE  黎扦烦菱   Posts: 4110
Do you mean extra escaping of & ?

eg)
in news: <title>You & me</title>
in xhld: You & amp; me

If so, try this pattern of template.

original:
<{$items[i].title|escape}>

modified:
<{$items[i].title|escape|regex_replace:'/\& amp\;([0-9a-zA-Z]{2,10}\;)/':'&\\1'}>
note: remove space between "&" and "amp"
Votes:9 Average:0.00
Previous post - Next post | Parent - No child | Posted on 2006/10/15 20:13
JMorris  企霹始   Posts: 4
Yes, but on a few different peices of code.

In xhld0_block_mixed.html, I changed
<{$block.items[i].title}>
To
<{$block.items[i].title|escape|regex_replace:'/\& amp\;([0-9a-zA-Z]{2,10}\;)/':'&\\1'}>

And in xhld0_feed.html, I changed
<td colspan="2" class="odd"><{$items[i].content}></td>
To
<td colspan="2" class="odd"><{$items[i].content|escape|regex_replace:'/\& amp\;([0-9a-zA-Z]{2,10}\;)/':'&\\1'}></td>

And
<td colspan="3"><a href="<{$items[i].link}>" target="_blank"><{$items[i].title}></a></td>
To
<td colspan="3"><a href="<{$items[i].link}>" target="_blank"><{$items[i].title|escape|regex_replace:'/\& amp\;([0-9a-zA-Z]{2,10}\;)/':'&\\1'}></a></td>

All with the space between & amp; removed.

So, in a word PERFECT!

Thanks!!!

James
Votes:7 Average:0.00

  Advanced search


Login
Username or e-mail:

Password:

Remember Me

Lost Password?

Register now!