[EventCalendar] EC3 - Include Only Posts That Match "Events"Category And "category x" in Upcoming Events List Widget

Joe jlindsay at fanningcommunications.com
Wed Apr 4 23:38:10 BST 2012


Pete,

I am not fluent in SQL at all. The programming skills I've acquired as a
site designer pretty much end when it comes to complex database
interactions.

Let me see if I understand correctly what the issue is.

The code is telling this query to grab the info I'm requesting, in this case
the category, from the "$ec3->schedule s" table in the database. Is that
correct?

If that¹s the case, I¹m assuming that the category_id of that post is not
contained in the "$ec3->schedule s" table, but contained in the wp_post
table. Is that correct?

If my assumptions above are correct, then how do I write a ³get_results²
query that includes getting all the information from both data base tables?
Is it possible to ³double ­up² the SELECT DISTINCT code (for both the ec3
schedule s table and the wp_post table) into a single ³get_results² query?




On 4/4/12 5:21 PM, "Dr. Peter Troxler" <peter.troxler at gmx.net> wrote:

> I guess this needs some acrobatics around the WP data model
> 
> see this: http://codex.wordpress.org/images/9/9e/WP3.0-ERD.png
> 
> and http://codex.wordpress.org/Database_Description
> 
> I am guessing that the wp_terms_relationships table has
> object_id which is the id of the table wp_post
> and
> term_taxonomy_id which is the term_taxonomy_id of wp_term_taxonomy
> 
> so you'd need to join wp_post and wp_term_taxonomy and add a where clause
> about term_taxonomy_id
> 
> are you sufficiently fluent in SQL?
> 
> / pt
> 
> PS. procrastrinating ...
> 
> On 5 Apr 2012, at 00:05 , Joe wrote:
> 
>> I¹ve narrowed this down some based on Pete¹s info.
>> 
>> It has to be in here (template-functions.php, line 594)
>> 
>> 
>>   // Find the upcoming events.
>>   $calendar_entries = $wpdb->get_results(
>>     "SELECT DISTINCT
>>        p.id AS id,
>>        post_title,
>>        start, 
>>        u.$ec3->wp_user_nicename AS author,
>>        allday 
>>      FROM $ec3->schedule s
>>      LEFT JOIN $wpdb->posts p ON s.post_id=p.id
>>      LEFT JOIN $wpdb->users u ON p.post_author = u.id
>>      WHERE p.post_status='publish'
>>            AND end>='$ec3->today' $and_before
>>      ORDER BY start $limit_numposts"
>>   );
>> 
>> I¹m figuring I have to add (after the Where ) something like ³AND
>> cat_ID='40'². However, I don¹t think I¹m calling the category id of the post
>> correctly.
>> 
>> Anyone see what I¹m doing wrong?
>> 
>> Any direction is appreciated.
>> 
>> Joe 
>> 
>> 
>> On 4/4/12 3:12 PM, "Dr. Peter Troxler" <peter.troxler at gmx.net> wrote:
>> 
>>> Joe
>>> 
>>> I see Š widget.php it is pulling the ec3_get_events() function which is
>>> defined in template-functions.php from line 356
>>> 
>>> so you could clone that function to ec3_get_majorevents() and either modify
>>> the SQL statement in there or the foreach loop as suggested earlier
>>> 
>>> / Peter
>>> 
>>> On 4 Apr 2012, at 21:57 , Joe wrote:
>>> 
>>>> Re: [EventCalendar] EC3 - Include Only Posts That Match "Events"Category
>>>> And "category x" in Upcoming Events List Widget
>>>> Peter,
>>>> 
>>>> Exactly on point. The problem is in the way the EC3 upcoming event list
>>>> widget is coded. I cannot find in the code where to place any code that
>>>> defines that the post must also match (&&) the ³major Events² category. I
>>>> believe it is in the widget.php file in the section between lines 102 and
>>>> 143:
>>>> 
>>>>   /** Upcoming Events widget. */  function ec3_widget_list($args)  {
>>>> extract($args);    $options = get_option('ec3_widget_list');        echo
>>>> $before_widget . $before_title;    echo
>>>> ec3_widget_title($options['title'],'Upcoming Events');    echo
>>>> $after_title;    ec3_get_events(                  $options['limit'],
>>>> EC3_DEFAULT_TEMPLATE_EVENT,      EC3_DEFAULT_TEMPLATE_DAY,
>>>> get_option('date_format')          );    echo $after_widget;  }   function
>>>> ec3_widget_list_control()  {    $options = $newoptions =
>>>> get_option('ec3_widget_list');    if ( $_POST["ec3_list_submit"] )    {
>>>> $newoptions['title'] = strip_tags(stripslashes($_POST["ec3_list_title"]));
>>>> $newoptions['limit'] = strip_tags(stripslashes($_POST["ec3_limit"]));    }
>>>> if ( $options != $newoptions )    {      $options = $newoptions;
>>>> update_option('ec3_widget_list', $options);    }      $title =
>>>> ec3_widget_title($options['title'],'Upcoming Events');    $limit =
>>>> $options['limit'];            $ec3_limit_title =      __("Examples: '5', '5
>>>> days', '5d'. To display recent past events, use a negative number: '-5'.");
>>>> ?> 
>>>> Where in this code (if this is indeed the spot for that change) do I put it
>>>> and how should the code be written?
>>>> 
>>>> Joe
>>>> 
>>>> 
>>>> On 4/4/12 2:46 PM, "Dr. Peter Troxler" <peter.troxler at gmx.net
>>>> <x-msg://1204/peter.troxler@gmx.net> > wrote:
>>>> 
>>>>> the typical approach would be to clone the widget and add code to its loop
>>>>> that skips events that are only "events" and not "major events".  not a
>>>>> very efficient approach, but works.
>>>>> 
>>>>> / pt
>>>>> 
>>>>> On 4 Apr 2012, at 21:41 , Joe wrote:
>>>>> 
>>>>>> EC3 - Include Only Posts That Match "Events" Category And "category x" in
>>>>>> Upcoming Events List Widget
>>>>>> All,
>>>>>> 
>>>>>> I¹ve been scouring sites and the code and cannot figure this out.
>>>>>> 
>>>>>> I want the ³Upcoming Event² list (using the widget in the sidebar) to
>>>>>> display only posts that match the ³Events² category (the one used for all
>>>>>> event posts) AND another category, ³Major Events².
>>>>>> 
>>>>>> Essentially, I only want the ³Major Events² to show in the Upcoming
>>>>>> Events list in the sidebar.
>>>>>> 
>>>>>> Why not use the Category Posts Widget to only show ³Major Events²? - I
>>>>>> tried that. And it does show posts from the ³Major Event² category. The
>>>>>> problem is, the list sorts by post date, not the date of the event. I
>>>>>> scoured the EC3 code trying to find the variable that controls the event
>>>>>> date to try to add it as a sort option to the category list, but cannot
>>>>>> find where that variable is defined in the EC3 code and can be recalled.
>>>>>> 
>>>>>> I need a solution that either:
>>>>>> € Adds the EC3 event date variable to the Category Posts widget for
>>>>>> sorting.
>>>>>> 
>>>>>> Or
>>>>>> 
>>>>>> 2. Lets me filter the ³Upcoming Events² posts by using the additional
>>>>>> category designation to exclude some Event posts.
>>>>>> 
>>>>>> Any help (or even a pointing in the right direction) would be
>>>>>> appreciated.
>>>>>> 
>>>>>> Joe
>>>>>> _______________________________________________
>>>>>> Blog: http://wpcal.firetree.net/
>>>>>> EventCalendar at firetree.net <x-msg://1204/EventCalendar@firetree.net>
>>>>>> mailing list
>>>>>> Unsubscribe: http://penguin.firetree.net/eventcalendar
>>>>> 
>>>>> 
>>>>> _______________________________________________
>>>>> Blog: http://wpcal.firetree.net/
>>>>> EventCalendar at firetree.net <x-msg://1204/EventCalendar@firetree.net>
>>>>> mailing list
>>>>> Unsubscribe: http://penguin.firetree.net/eventcalendar
>>>> _______________________________________________
>>>> Blog: http://wpcal.firetree.net/
>>>> EventCalendar at firetree.net mailing list
>>>> Unsubscribe: http://penguin.firetree.net/eventcalendar
>>> 
>>> 
>>> _______________________________________________
>>> Blog: http://wpcal.firetree.net/
>>> EventCalendar at firetree.net mailing list
>>> Unsubscribe: http://penguin.firetree.net/eventcalendar
>> _______________________________________________
>> Blog: http://wpcal.firetree.net/
>> EventCalendar at firetree.net mailing list
>> Unsubscribe: http://penguin.firetree.net/eventcalendar
> 
> 
> _______________________________________________
> Blog: http://wpcal.firetree.net/
> EventCalendar at firetree.net mailing list
> Unsubscribe: http://penguin.firetree.net/eventcalendar

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://penguin.firetree.net/pipermail/eventcalendar/attachments/20120404/e677f7b0/attachment-0001.htm>


More information about the EventCalendar mailing list