Home › Forums › Calendar Products › Filter Bar › Using PHP to generate information
- This topic has 3 replies, 2 voices, and was last updated 10 years, 6 months ago by
George.
-
AuthorPosts
-
September 24, 2015 at 7:01 am #1008236
fifteen15studios
ParticipantHi Modern Tribe,
I am messing around with our site and the new filter bar, and I was wondering how I could use PHP to display my event categories (and other attributes) the way you do in your filter bar?
What I’d like to do is generate something which looks like this for all categories I have:
<ul> <li class="[ClassOfCategory]"><label style="color: [ColorOfCategory];"><input type="checkbox" value="[ValueOfCategory]" checked='checked' name="tribe_eventcategory[]" data-slug="[SlugOfCategory]" />[NameOfCategory]</label></li> ... </ul>I’m pretty good with PHP, but I do not know which functions or variables I should be calling in order to develop a list in this manner. Could you please give me any assistance you can? I would appreciate it.
Also, I would like to add that I plan on inserting this in a popup area outside the main content of the web page. I should also add that I have the code working, but the list is hard-coded. It’s just a matter of making it populate dynamically which I find difficult. I understand the logic, but I don’t know your variable names or how to call your functions.
Thanks!
Brendan-
This topic was modified 10 years, 7 months ago by
fifteen15studios.
September 24, 2015 at 1:38 pm #1008491George
ParticipantHey Brendan,
We unfortunately do not offer any support for custom code, so there’s not much specific advice I can share here.
In general, however, it sounds like the things needed for your customization are very general WordPress questions related to custom taxonomies and such; in other words, there’s not really anything specific to The Events Calendar or Filter Bar that would come into play with your list.
To see how Filter Bar does it, I’d recommend just diving right into the Filter Bar code โย check out the code in the /src/ folder, specifically, and read through the class Tribe__Events__Filterbar__Filters__Category.
In that class, for example, is a line of code like this which gets all the categories:
// Load all available event categories
$source = get_terms( Tribe__Events__Main::TAXONOMY, array( 'orderby' => 'name', 'order' => 'ASC' ) );That uses the general WordPress function get_terms(), which sounds like it’d be quite useful for your own customizations and can be read about here โ https://codex.wordpress.org/Function_Reference/get_terms
I hope all of this information helps!
โ George
September 29, 2015 at 8:53 am #1009712fifteen15studios
ParticipantThanks!! I’ll probably try that soon.
September 30, 2015 at 9:53 am #1010098George
ParticipantAwesome! Best of luck with your customizations @Brendan ๐
โ George
-
This topic was modified 10 years, 7 months ago by
-
AuthorPosts
- The topic ‘Using PHP to generate information’ is closed to new replies.
