Support

Home Forums Event Espresso Premium $category_identifier returns NULL

$category_identifier returns NULL

Posted: November 27, 2012 at 12:06 pm

Viewing 5 reply threads


spark

November 27, 2012 at 12:06 pm

In the event_list_display.php each event div#event_data-X is supposed to get various classes assigned via PHP variables. One of these variables is $category_identifier which I assume is supposed to return the name(s) of the category that the event belongs to.

Instead, it returns NULL. It does this in the original file and in a custom file.

Any ideas on how to get an event’s category/categories on this page?


spark

November 27, 2012 at 12:23 pm

I just looked through the mySQL tables a little. I noticed that in the ‘jfewp_events_detail’ table there is a column called ‘category_id’. Each event that I have created has a value of NULL for this column, even though each one is assigned to at least one category.

The ‘jfewp_events_category_rel’ and ‘jfewp_events_category_detail’ tables look okay though, so maybe this $category_identifier variable is just trying to pull a value from the wrong place? I guess I’ll just write my own function so this works…


spark

November 27, 2012 at 12:50 pm

Well I made a function that returns category IDs for a given event. YOU’RE WELCOME 😛 Here is the function to add to custom_functions.php
function event_category_list($event_ID){
global $wpdb;

$query = "SELECT cat_id FROM ".EVENTS_CATEGORY_REL_TABLE." WHERE event_id=$event_ID";
$cat_list = $wpdb->get_results($query);

$output = '';
foreach($cat_list as $category){
    $output .= "category-".$category->cat_id." ";
}
return $output;
}

And in event_list_display.php, use this for the opening div (Note this is really hard to do since the code view still seems to apply HTML entities to what I type, just imagine your own HTML and ?php brackets ):

div id="event_data-?php echo $event_id ?" class="event_data ?php echo $css_class; ?   ?php echo $category_identifier; ?   ?php echo event_category_list($event_id); ? "

I’m not marking this as resolved since $category_identifier is probably supposed to return something other than NULL for everything.


spark

November 27, 2012 at 12:58 pm

UGH these forums are crap. Apparently I can only edit a post once and doing so mangles the code samples. So here is that function again (I hope this displays correctly):

function event_category_list($event_ID){
global $wpdb;

$query = "SELECT cat_id FROM ".EVENTS_CATEGORY_REL_TABLE." WHERE event_id=$event_ID";
$cat_list = $wpdb->get_results($query);

$output = '';
foreach($cat_list as $category){
    $output .= "category-".$category->cat_id." ";
}
return $output;
}


spark

November 27, 2012 at 1:00 pm

Just remember to replace the &gt; and &lt; with the correct brackets. Wait a sec, typing an actual < turns it into an html entity, but typing the entity code displays the bracket like normal… I don’t get this WYSIWYG, is this BuddyPress?


Josh

  • Support Staff

November 27, 2012 at 1:03 pm

Hi there,

Thanks for posting this. I’ll pass this along to the dev team. From what I remember, it will add the category_identifier if there’s a category set as a parameter. It’s when there’s not a category parameter in the event_list shortcode that NULL is returned, which your fix addresses.

Viewing 5 reply threads

The support post ‘$category_identifier returns NULL’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso