Shortcut Codes

This topic contains 16 replies, has 2 voices, and was last updated by  Stephen Harris 11 years, 2 months ago.

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #2994

    I’m having trouble showing only specific event categories.
    I’m trying everything but it displays all the events from all categories no matter what.

    [eo_events events-category=’lake-stocking’]
    [eo_events events_category=”lake-stocking”]
    [eo_event events_category=”lake-stocking”]

    Any help would be great.

    Thanks

    Alfonzo Burton
    #2995

    I finally figured it out.
    The documented attribute is events_category with an S and it works with event_category without an S.

    Thanks

    Alfonzo Burton
    #2996

    Actually I see you have it right for some reason I was adding an S.
    Good work

    Alfonzo Burton
    #3516

    I am having trouble to use the event_category attribute of the eo_events ShortCode.

    I use the code

    [eo_events showpastevents=false event_category=”evenement-interculturel”] %event_title% le %start{j M Y}{ g:i:a}%, au %event_venue% [/eo_events]

    at the end of a page.

    It does generate a list of events. But the list did not select only events from the category “evenement-interculturel” and instead generate a list of all the inputs.

    I need help, since I don’t know how to debug or find info on what is wrong.

    the page can be found at http://fssf.orgfree.com/?page_id=10

    the event category as a name:

    Evènement interculturel

    and an id: evenement-interculturel.

    I tried both name and id as the value for the event_category attribute: nothing is working as expected.

    Thanks for your help.

    Guillaume
    #3519

    Hi Guillaume,

    Mmmm… its definitely not displaying the events it should on your site, but I’m unable to replicate the bug. Could you try disabling any other plug-ins and switching to Twenty Eleven/Tweleve theme to check that its not a plug-in conflict?

    Stephen Harris
    #3564

    I did as you asked. It did not improve the thing at all.

    At least, the first glance you gave tell I am using the correct sytax ? right ?

    How can you use some specific code (even in a template) to try to dig the problem ?

    Can you give me some hint what to do or where to search ?

    Thanks Stephen.

    Guillaume
    #3565

    Another question what is supposed to happen if the category I try to select do not exist ?

    It should select nothing right ? Because right now it looks like it anyhow select all events.

    Maybe it is some hint to you on where to search the problem.

    Thx

    Guillaume
    #3570

    Hi Guillaume,

    Regarding selecting categories that do not exist – I’m not sure. The shortcode simply invokes WP_Query() – so whatever the defaut behaviour of that is when querying posts in a taxonomy that does not exist.

    As mentioned above, the shortcode invokes WP_Query and does this via eventorganiser_list_events() (source) – a terrible function that needs refactoring.

    Anyway, as you can see its a simple WP_Query – and the query variable may contain the ‘event-category’ key to query the events.

    The handler for the shortcode (which first turns the attributes into a query whichWP_Query will understand before using the above), can be found here: https://github.com/stephenharris/Event-Organiser/blob/1.7.3/classes/class-eventorganiser-shortcodes.php#L142

    Stephen Harris
    #3574

    Hi Stephen,

    in the class-eo-event-list-widget.php file in function eventorganiser_list_events the call to the query is

    $eo_event_loop = new WP_Query($query);

    And in my case the query is an array containing

    -1
    event
    “vide”
    eventstart
    ASC
    1
    “vide”
    1
    showpastevents=false
    “vide”
    event_category=”evenement-interculturel”

    question1 : Does this look right ?
    question 2: The taxonomy is event-category. But in the doc it was stated that the attribute should be event_category and not the taxonomy.
    Can you explain me the mecanism that let WP_Query know how to change event_category to event-category ? I don’t understant how this query could give us the good result unless the selection is done elsewhere ( in the eo_get_event_classes for instance ?)

    Thanks again for your time

    Guillaume
    #3575

    sorry my french was not translated. By “vide” I mean that it is an empty string.

    Guillaume
    #3577

    I dug a little more:

    in the file event-organiser-event-functions.php

    in the function eo_get_event_classes

    there is this final call to the filtering function:

    apply_filters(‘eventorganiser_event_classes’, $event_classes, $post_id, $occurrence_id)

    My question: eventorganiser_event_classes do not refer to any function in the plugin files. What is it ? A somehow database entry ?
    can you help me understanding how this works ?

    Thanks.

    Guillaume

    Guillaume
    #3578

    The function eo_get_event_classes() simply returns an array of HTML classes corresponding to the event (see doc).

    The `apply_filters’ part simply allows other plug-ins/themes to add additional classes to that array or remove some.

    The function doesn’t play any role in retrieving events, but simply, for specified occurrence generates HTML classes for that occurrence based on (for example) – the event venue/category. E.g. it includesthe class ‘eo-event-cat-evenement-interculturel’.

    And yes, the attribute is ‘event_category’ while ‘event-category’ is the taxonomy name. The reason for this is that hyphens do not work well in shortcodes! The shortcode handler (see source) converts the shortcode attribute into something WP_Querywill understand.

    Is there any relationship between ‘evenement-interculturel’ and ‘rtc’? That seems to be the only other category showing…?

    Stephen Harris
    #3580

    Then there is something wrong in my case since, as I told you, the attributes that I see in my case and are directly passed to WP_Query are

    -1 ; event ; “empty” ; eventstart ; ASC ; 1 ; empty ; 1 ; showpastevents=false ; empty ; event_category=”evenement-interculturel”

    Where you can see the event_category was not changed. Where is made that call to “handle_eventlist_shortcode” function ?

    Sorry to bug you. I don’t know much of WP_Query…. I hope I do not anoy you too much…

    Thanks again.

    G.

    guillaume
    #3581

    Not at all 🙂

    You won’t find an explicit call to it – its called automatically when the shortcode is parsed. Lines 143-149 are where taxonomy attributes are converted. You can check the input against the output. Then $atts array should contain the attributes and their values,e.g.

     array(
        'showpastevents' => 1,
        'event_category' => 'evenement-interculturel',
      )
    

    The first thing that function does (should do) is replace event_* with event-* (for ‘category’, ‘venue’ and ‘tag’)

    Stephen Harris
    #3582

    There is something wrong:

    the test:

    foreach ($taxs as $tax){
    if(isset($atts['event_'.$tax])){
    $atts['event-'.$tax]= $atts['event_'.$tax];
    unset($atts['event_'.$tax]);
    }

    fails .

    The thing is that if I output the content of the atts array I get:

    showpastevents=false
    empty
    event_category=”evenement-interculturel”

    To my understanding the entries are stored as vectors and not as a map so that

    $atts[‘event_’.$tax]

    makes no sense (the indexes are probably integers and not the attributes)

    Does my remark make sense ?

    Any hint ?

    Guillaume
Viewing 15 posts - 1 through 15 (of 17 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.