Support

Home Forums Custom Files Add-on (EE3) Multiple CSS Dropdown Lists on the Same Page

Multiple CSS Dropdown Lists on the Same Page

Posted: June 11, 2013 at 7:21 pm


Cam Bassignan

June 11, 2013 at 7:21 pm

Hi, I am trying to get several different CSS Dropdown lists (from plugin custom files 3.1) on the same page showing events in different categories. Once I add more than 1 CSS Dropdown using the shortcode, only 1 of the dropdowns will open (the first one).

I assume this is a Javascript problem and has to do with the DIV ID not changing. In the code, there is a ‘6’ next to the ids and classes, as well as in the OnClick events. I figure the best way to solve the problem is to dynamically call the event category to have this “6” changed to the categories id. Would this solve the problem?

How would I get the event category id to ‘echo’ it onto the div ids? I have tried to call the category ids with no luck.

Thank you in advance for help!


Josh

  • Support Staff

June 12, 2013 at 11:53 am

Hi Cam,

I checked into this and it looks to me that the CSS Dropdown was built to allow one dropdown per page. I think you’re on the right track with the idea of grabbing the category ID. I’m going to check in with the resident code Ninja to get his thoughts.


Cam Bassignan

June 12, 2013 at 12:24 pm

Thanks Josh!

The javascript does appear to be calling the “DIV ID” + ‘ID’ (ie. “lhsHeader” + ‘6″) to change the class and create the dropdown effect….So having the 6 dynamically changed to the category id should solve the problem. I just don’t know exactly how to call the event category id from the database or if it has a different call from standard WP.

Below is the current SQL call setup:

[code language=”php”]if ($type == ‘category’){
$sql = “SELECT e.* FROM ” . EVENTS_CATEGORY_TABLE . ” c “;
$sql .= ” JOIN ” . EVENTS_CATEGORY_REL_TABLE . ” r ON r.cat_id = c.id “;
$sql .= ” JOIN ” . EVENTS_DETAIL_TABLE . ” e ON e.id = r.event_id “;
$sql .= ” WHERE c.category_identifier = ‘” . $category_identifier . “‘ “;
$sql .= ” AND e.is_active = ‘Y’ “;
}else{
$sql = “SELECT e.* FROM ” . EVENTS_DETAIL_TABLE . ” e “;
$sql .= ” WHERE e.is_active = ‘Y’ “;
}[/code]

This may not be the right section of the SQL, but how can we add the call to the Event Category Id? Hopefully your code ninja will know…


Cam Bassignan

June 12, 2013 at 12:28 pm

Oh yea, one other thing, which may or may not be of serious concern. Firebug in firefox is popping up this error associated with the main-javascript.js file every time the dropdown is clicked:
ReferenceError: rhsContent is not defined

rhsContent(page);

 


Sidney Harrell

June 12, 2013 at 4:52 pm

I got it working using this modification: https://gist.github.com/sidharrell/5769805
it starts at line 165 of css_dropdown.php


Sidney Harrell

June 12, 2013 at 5:01 pm

I found that I also had to modify line 130 of custom_functions.php to be:

$registration_url = $externalURL != '' ? $externalURL : espresso_reg_url($event_id);

to get the links in the dropdowns to work.


Cam Bassignan

June 12, 2013 at 7:04 pm

Perfect! The code on github worked. I didn’t have to make the change to the custom_functions.php for the links to work.

Have to say it was a great idea to just have a random number generated instead of trying to create a SQL call. Much simpler.

Thanks Sidney…

The support post ‘Multiple CSS Dropdown Lists on the Same Page’ 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