[EventCalendar] fix to get category listing to work

Alex Tingle alex at firetree.net
Sat Feb 4 16:24:27 UTC 2006


Hi Jonyo,

Thank's very much for that. I've put your change into a new release package:

 http://blog.firetree.net/wp-content/plugins/eventcalendar304.zip

Can somebody test this for me on Wordpress 2.0? If it is confirmed to fix the event category listing, then I'll officially release it.

I'm very surprised to see this patch. category_id is an integer - if Wordpress is treating it as a string in SQL, then that's a bug in Wordpress. Although I just checked, and MySQL allows it.

I like your full-size calendar on the category listing page. This is a common request, and it's nice to see some code for it. I'd like to see a different stylesheet for the full calendar - the small sidebar fonts look out of place in the main part of the page.

-Alex

--

On Sat, 4 Feb 2006 02:30:33 -0600
<ohheyyo at gmail.com> wrote:

> Got a fix to get category list to work.  To all those that just want the
> fix, here it is:
> find this code in eventcalendar3.php:
> -------copy (don't copy this line)
>   $ec3->is_listing =
>     (preg_match("/\bcategory_id\s*=\s*$ec3->event_category\b/",$where) ||
> 
> preg_match("/\bcategory_nicename\s*=\s*'$event_cat_nicename'/",$where));
> -------end copy (don't copy this line)
> 
> and change it to:
> -------copy (don't copy this line)
>   $ec3->is_listing =
>     (preg_match("/\bcategory_id\s*=\s*'?$ec3->event_category'?\b/",$where)
> ||  //fix by jonyo
> 
> preg_match("/\bcategory_nicename\s*=\s*'$event_cat_nicename'/",$where));
> -------end copy (don't copy this line)
> 
> Now for those who want to know the technical details of what was wrong (not
> for people with heart conditions or who are scared by geek jargon):
> 
> I was doing the standard troubleshooting, and noticed that $where had
> category_id
> = '2' in it when going to the category page dealing with the calendar.  Then
> I looked at that top line, and it is trying to find category_id = # w/o the
> single quotes.  So I added the single quote, followed by ? so that it will
> match whether it has the single quote there or not (so it will work for
> category_id = '#' OR category_id = # )
> 
> Amazing how something so simple as a ' can mess things up, and be so hard to
> find...  If someone has already found this fix and posted it then mybad,
> guess I'm not as special as I thought.
> 
> Added bonus:
> Below this line is OPTIONAL and is not needed for the category listing fix
> to work.
> 
> Heres what I got it to do:  when on category page, show the calendar big,
> but everywhere else show it on the sidebar:
> 
> BACK UP ALL FILES before changing them!  These hacks work for me, but might
> or might not for everyone else depending on what themes you use, what
> plugins, etc...
> 
> in sidebar.php for your theme, add this in place of the standard sidebar
> code:
> -------copy (don't copy this line)
> global $custom_show_cal;
> 
> if ($custom_show_cal!='show_main'){
>         ?>
>         <li style="margin-top:30px;">
>            <?php ec3_get_calendar(); ?>
>         </li><?php } ?>
> -------end copy (don't copy this line)
> 
> now in index.php for your template, look for (this might be different for
> your theme):
> -------copy (don't copy this line)
>     <?php if (have_posts()) : ?>
> -------end copy (don't copy this line)
> 
> right before it add:
> -------copy (don't copy this line)
> <?php
>         global $custom_show_cal;
>         if ($custom_show_cal=='show_main'){ec3_get_calendar();}
>         ?>
> -------end copy (don't copy this line)
> 
> now on eventcalendar3.php page, find:
> -------copy (don't copy this line)
>   if($ec3->is_listing && $ec3->advanced && !$wp_query->is_date)
>   {
>     // reverse date restriction for event category listing
> -------end copy (don't copy this line)
> 
> right after it, add:
> -------copy (don't copy this line)
>     global $custom_show_cal; //jonyo custom code to tell sidebar to not show
> calendar.
>     $custom_show_cal='show_main';
> -------end copy (don't copy this line)
> 
> Attached are my modified sidepanel.php and index.php and eventcalendar3.php for
> everyone's viewing pleasure.  Do NOT use the sidepanel.php and
> index.phpunless you happen to have the same theme as me, or it will
> make your site
> look weird and possible break the site.  They are meant as reference only,
> you need to figure out where and how to implement it in your particular
> theme.
> 
> Example of working category listing w/ above show full calendar hack:
> http://wendyleigh.net/category/cal
> 
> Hope this helps a few of you.
> 
> -Jonyo
> (aka)
> Jonathan Foote


-- 
:: Let me solve your problems: http://www.firetree.net/consulting/
:: alex.tingle AT firetree.net  +44-7901-552763 



More information about the EventCalendar mailing list