[EventCalendar] ec3_get_events() not translating ampersands into character entities

Dr. Peter Troxler peter.troxler at gmx.net
Wed Oct 3 18:05:14 UTC 2007


you will have to tweak the ec3_get_events() in template_tags.php  
function in a very peculiar way:

find this section

       $data['TITLE'] =$entry->post_title;
       $data['LINK']  =get_permalink($entry->id);
       $data['AUTHOR']=$entry->author;

and change it to

       $data['TITLE'] =htmlentities(html_entity_decode($entry- 
 >post_title));
       $data['LINK']  =htmlentities(html_entity_decode(get_permalink 
($entry->id)));
       $data['AUTHOR']=htmlentities(html_entity_decode($entry->author));

this essentially converts all html (that might eventually be sitting  
there) to normal characters and converts them back to html

I tested it with the title only, so link and author at your own risk  
(as of course always the standard disclaimer that nothing is  
guaranteed to work or not to break the rest of your blog etc.) test  
it first on a defined testcase and ideally in a test blog before  
applying it to your production platform. always backup files & data,  
etc.

It works well visually and validates for both an & or a simple &  
put in the title.

However, be warned, there seem to be changes in upcoming versions of  
WP re html in the title.

hope this helps

/ pt

On 3-okt-2007, at 19:03, ejm wrote:

> Running WP2.0.11 and EC3.1.0  I am using ec3_get_events() on the
> lefthand sidebar of a wordpress I run with the following code:
>
> ec3_get_events('1000 days',' <a href="%LINK%" title="%DATE% -
> %TITLE%"><b>%DATE%</b><span style="display:none">:</span>
> %TITLE%</a>','');
>
> Whenever there is an ampersand or other nonstandard character in the
> title or link, it causes the page to not validate in XHTML. Not
> knowing a whole lot about PHP, how do I go about encoding an "if,
> else"  to make sure that ampersands and non-standard characters are
> translated to their character entities the way they are in the rest of
> wordpress? (I've searched as best I can for this answer via google but
> it must be a "need to know the answer before asking the question" kind
> of problem)
>
> Please note that omitting ampersands, quotation marks, apostrophes and
> non-standard characters from titles is not necessarily an option. This
> particular wordpress is filled in by someone else who knows even less
> about coding than I do and who will not be able to understand why
> there is a need to omit the characters.
>
> Thank you.
>
> -EMorris
>
> P.S. The address is peacemakers.ca.etherwork.net/bulletins/  In an
> effort to keep spammers at bay, I would prefer that the address of the
> site NOT be made into a link.
>
> _______________________________________________
> Blog: http://wpcal.firetree.net/
> EventCalendar at firetree.net mailing list
> Unsubscribe: http://penguin.firetree.net/eventcalendar




More information about the EventCalendar mailing list