[EventCalendar] ec3_get_events() not translating ampersands into
character entities
ejm
cq547 at torfree.net
Fri Oct 5 13:41:14 UTC 2007
Running WP2.0.11 and EC3.1.0
>it turns out that it was not the event calendar that was causing the validation errors.
Well, rats. I fixed the Get Custom Field Value plugin error. And alas,
my analyis was incorrect. ec3_get_events() IS still causing validation
errors.
Once again, this is the coding I am using on the left sidebar of
peacemakers.ca.etherwork.net/bulletins/:
ec3_get_events('1000 days',' <a href="%LINK%" title="%DATE% -
%TITLE%"><b>%DATE%</b>: %TITLE%</a>','');
I also have an events page that uses the following coding:
ec3_get_events('1000 days','%DATE%: <a href="%LINK%" title="%DATE%:
%TITLE%">%TITLE%</a>','','j',"%MONTH%:");
On both those pages, if there are ampersands in %TITLE%, they are NOT
rendered into their entities in the coding. (I believe I did not make
it clear that I want any ampersand to be turned into & for the
html pages)
I have tried various permutations of Dr.Troxler's fix - (note that I
have not included "html_entity_decode") but I continue to get
validation failure.
In eventcalendar3 > template-functions.php I have tried replacing
$data['TITLE'] =$entry->post_title;
with
...........................
$data['TITLE'] =htmlentities($data['TITLE']);
..........................
With that coding, the ampersands do get translated and the main page
displays in Firefox. However, any attempt to validate the page fails:
the validation page states that there are now characters that do not
belong in UTF-8.
But the events page fails to display anything after the date. The link
and the title are gone.
Is there a way to deal with it on the theme pages? With something
along the lines of "htmlentities(%TITLE%)" in the coding?? I know that
this will just cause the word "htmlentities" to appear on the page. I
have stared at eventcalendar3.php and template-functions.php but alas,
I am not skilled enough to do anything but stare. Any ideas would be
most welcome.
Thank you.
-EMorris
P.S. In an effort to keep spammers at bay, I would prefer that the
address of my wordpress site NOT be made into a link.
On Wed, 3 Oct 2007 20:05:14 +0200, "Dr. Peter Troxler" wrote:
>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.
More information about the EventCalendar
mailing list