Support

Home Forums Event Espresso Premium bug in function espresso_event_category_data

bug in function espresso_event_category_data

Posted: October 3, 2013 at 2:55 am


Nicolas Alberto

October 3, 2013 at 2:55 am

Hi
I think there is a bug in the function espresso_event_category_data in main.php

those lines
$category_data[‘category_identifier’] .= $result->category_identifier . ‘ ‘;
$category_data[‘category_name’] .= $result->category_name . ‘ ‘;
$category_data[‘category_desc’] .= $result->category_desc . ‘ ‘;
$category_data[‘display_desc’] .= $result->display_desc . ‘ ‘;
$category_data[‘category_meta’] .= $result->category_meta . ‘ ‘;

should read that instead I think

$category_data[‘category_identifier’] = $result->category_identifier . ‘ ‘;
$category_data[‘category_name’] = $result->category_name . ‘ ‘;
$category_data[‘category_desc’] = $result->category_desc . ‘ ‘;
$category_data[‘display_desc’] = $result->display_desc . ‘ ‘;
$category_data[‘category_meta’] = $result->category_meta . ‘ ‘;

Cheers
Nic


Dean

October 3, 2013 at 5:00 am

Hi

Thanks for that Nic, it looks wrong to me too, but I will put it under the nose of a seasoned developer and they can check it out.


Josh

  • Support Staff

October 3, 2013 at 12:26 pm

I think if you try your suggested code change the category name shortcode will only display one category name even if the event has more than one category assigned to it. It will normally display each category name that’s assigned to the event.


Nicolas Alberto

October 3, 2013 at 8:16 pm

Yes I think I did this in a rush but still

With the current code if I have two categories says kids and adults,
it returns an array with values for the $category_data[‘category_name’] keys as
1 -> kids
2 -> kids adults
and I think it should be
1-> kids
2-> adults

I my case I just took the function and got it to spit direcly the html in the foreach loop so I did not test if it returns the array correctly after the suggested change.

Thanks anyway for the quick replies. Your support is fantastic. I will stop bothering you when implementation is finished 🙂 on my side.


Sidney Harrell

October 14, 2013 at 12:28 pm

What I get when I var_dump the result of that function is:

array(5) { ["category_identifier"]=> string(44) "category-2-1381774231 category-1-1381774219 " ["category_name"]=> string(22) "Category 2 category 1 " ["category_desc"]=> string(2) " " ["display_desc"]=> string(4) "N N " ["category_meta"]=> string(220) "a:3:{s:11:"use_pickers";s:1:"Y";s:16:"event_background";s:7:"#486D96";s:16:"event_text_color";s:7:"#ebe6e8";} a:3:{s:11:"use_pickers";s:1:"Y";s:16:"event_background";s:7:"#486D96";s:16:"event_text_color";s:7:"#ebe6e8";} " }

There is a bug in this line:

if ($num_rows > 0 && $all_cats = FALSE) {

It should be:

if ($num_rows > 0 && $all_cats == FALSE) {

so that the call should be:

$temp = espresso_event_category_data($event_id, TRUE);
var_dump($temp);

If I change the code to be:

foreach ($wpdb->last_result as $key=>$result) {
				$category_data[$key]['category_identifier'] = $result->category_identifier;
				$category_data[$key]['category_name'] = $result->category_name;
				$category_data[$key]['category_desc'] = $result->category_desc;
				$category_data[$key]['display_desc'] = $result->display_desc;
				$category_data[$key]['category_meta'] = $result->category_meta;
			}

Then I do get the output:

array(2) { [0]=> array(5) { ["category_identifier"]=> string(21) "category-2-1381774231" ["category_name"]=> string(10) "Category 2" ["category_desc"]=> string(0) "" ["display_desc"]=> string(1) "N" ["category_meta"]=> string(109) "a:3:{s:11:"use_pickers";s:1:"Y";s:16:"event_background";s:7:"#486D96";s:16:"event_text_color";s:7:"#ebe6e8";}" } [1]=> array(5) { ["category_identifier"]=> string(21) "category-1-1381774219" ["category_name"]=> string(10) "category 1" ["category_desc"]=> string(0) "" ["display_desc"]=> string(1) "N" ["category_meta"]=> string(109) "a:3:{s:11:"use_pickers";s:1:"Y";s:16:"event_background";s:7:"#486D96";s:16:"event_text_color";s:7:"#ebe6e8";}" } }

The support post ‘bug in function espresso_event_category_data’ 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