Using PHP to generate information

Home Forums Calendar Products Filter Bar Using PHP to generate information

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1008236
    fifteen15studios
    Participant

    Hi 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

    #1008491
    George
    Participant

    Hey 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

    #1009712
    fifteen15studios
    Participant

    Thanks!! I’ll probably try that soon.

    #1010098
    George
    Participant

    Awesome! Best of luck with your customizations @Brendan ๐Ÿ™‚

    โ€” George

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Using PHP to generate information’ is closed to new replies.