• Resolved magus824

    (@magus824)


    Hello there! First, I would like to say thank you for the 2.0 update to this already great plugin.

    There are two things that I want to do, but haven’t found the documentation for it, if someone could help?

    1) I would like to be able to list all categories above the calendar view, so that if someone wanted to just see the calendar within a specific event category, they would be able to. Example: Let/s say I have two categories, “East Coast” and “West Coast”. When I am looking at the Event Calendar, I want to be able to have those categories listed, so that when someone clicks “West Coast”, they get to see a calendar with just the items pertaining to “West Coast”.

    2) I feel I should know this, but I can’t figure it out: I would like it so that the “Next Event” widget will also show the thumbnail for that event.

    Thanks in advance for any help you can give me!

    https://www.ads-software.com/extend/plugins/the-events-calendar/

Viewing 15 replies - 1 through 15 (of 21 total)
  • #1 – if you look in the template tags folder you will see a function called “tribe_meta_event_cats( $label=null, $separator=’, ‘)”. Use that to list out the cats and populate a select. Then use a bit of javascript to point the site to the category page (for example https://www.mysite.com/events/category/featured/) based upon the cat selected. It will take a bit of noodling but shouldn’t be too hard.

    #2 – it is totally doable but I don’t know the answer offhand (dead sick with the flu and traveling) – replying via email.

    best of luck

    Thread Starter magus824

    (@magus824)

    Thanks for the quick response, and sorry to hear about you being sick!

    So I tried using the “tribe_meta_event_cats(”);” function, but what I am getting is only the first category. For an example of what is happening, see below:

    https://dev.mesacountylibraries.org/events/

    I tried calling all posts and listing categories, but then a single category gets listed more than once. Any help is again, appreciated, and I hope you get better!

    Thanks!

    I’m looking for a similar solution. What category page? Not sure how to do this

    A widget would be awesome

    I’d tried the above code from Shane also. And I also only get one category not all of my categories. Does this function return an array of categories?

    I found out the function above only shows the categories for the events on the single event page. And on the calendar if you are in the default calendar you will only show the categories for the current Day. I also tried adding it to the widget and the only show the category for you to upcoming events. No idea how to show all categories that are in a system for the events no matter what.

    Thread Starter magus824

    (@magus824)

    All right, for anyone in the future wondering how this can be done, I have been helped by the great people over at the Events Calendar Tribe website, and will put the code below:

    <?php
    
    		$terms = get_terms("tribe_events_cat");
     		$count = count($terms);
     		if ( $count > 0 ){
     		    echo "<ul>";
     		    foreach ( $terms as $term ) {
     		      echo "<li><a href='" . $term->slug . "'>" . $term->name . "</a></li>";
    
     		    }
     		    echo "</ul>";
     		}
    
    	?>

    What you do with this information is up to you! Happy coding!

    Thanks Magus!

    There is a problem with the link on this code. When you’re in the certain category the links don’t work. The following code works great.

    <?php
    		$terms = get_terms("tribe_events_cat");
     		$count = count($terms);
     		if ( $count > 0 ){
     		    echo "<ul>";
     		    foreach ( $terms as $term ) {
     		      echo "<li><a href='" .  get_site_url() . "/events/category/". $term->name." '>" . $term->name . "</a></li>";
    
     		    }
     		    echo "</ul>";
     		}
    
    	?>

    Now that we have the linking problem gone, but how do we put this into the drop down. I think I know the HTML part, and but I assume there must be some kind of JavaScript needed to accomplish the link once someone chooses one of the categories.

    Here is code for a drop down of categories. I put it into the grid view.

    <?php
    
    		$terms = get_terms("tribe_events_cat");
    
     		$count = count($terms);
    
     		if ( $count > 0 ){
    
    echo "<strong> Categories </strong>"; 
    
    echo "<script type='text/javascript'>function taclinkch(x){var y=document.getElementById(x).value;document.location.href=y}</script>";
     		    echo "<form action=''>  <select name='cats' id='cats' onchange='taclinkch(this.id)'>";
    
    echo "<option value='/*https://www.disabilityvoice.com/dvb/events/*/'>Select a Category</option>";
    
    echo "<option value='https://www.disabilityvoice.com/dvb/events/'>ALL</option>";
    
     		    foreach ( $terms as $term ) {
    
     		      echo "<option value='" .  get_site_url() . "/events/category/". $term->name." '>" . $term->name . "</option>";
    
     		    }
    
     		    echo "</select></form>";
    
     		}
    
    	?>

    There is one error in the code above for the drop down menu in the grid view containing all the categories. Plus creating my own widget having all the event categories I install the widget called WP PHP Widget an and put some code into that widget. The code has to be different in the widget though for the addresses to work. Here’s the code for both below. And also for it to work properly the select box of the grid view has to have a different ID than the idea of the select box in the widget. (ID or name)

    Code for drop down in grid view document

    <?php
    		$terms = get_terms("tribe_events_cat");
     		$count = count($terms);
     		if ( $count > 0 ){
    
    echo "<script type='text/javascript'>function taclinkch(x){var y=document.getElementById(x).value;document.location.href=y}</script>";
     		    echo "<form action=''>  <select name='eventcats' id='eventcats'   onchange='taclinkch(this.id)'>";
    
    echo "<option value=''>Select a Category</option>";
    
    echo "<option value='https://www.disabilityvoice.com/dvb/events/'>ALL</option>";
    
     		    foreach ( $terms as $term ) {
    
     		      echo "<option value='" .  get_site_url() . "/events/category/". $term->name." '>" . $term->name . "</option>";
     		    }
    
     		    echo "</select></form>";
    
     		}
    	?>

    Code for drop down of categories in the WP PHP Widget

    <?php
    		$terms = get_terms("tribe_events_cat");
     		$count = count($terms);
     		if ( $count > 0 ){
    
    echo "<script type='text/javascript'>function taclinkch(x){
    var y=document.getElementById('eventcatswidget' ).value;
    var currentURL=window.location.replace(y);
    }</script>";
    
    	    echo "<form action=''>  <select name='eventcatswidget' id='eventcatswidget' and onchange='taclinkch(this.id)'>";
    
    echo "<option value=' '>Select a Category</option>";
    
    echo "<option value='https://www.disabilityvoice.com/dvb/events/'>ALL</option>";
    
     		    foreach ( $terms as $term ) {
    
    		      echo "<option value='" .  get_site_url() . "/events/category/". $term->name." '>" . $term->name . "</option>";
     		    }
    
        echo "</select></form>";
     		}
    	?>

    If you need any help with this issue, contact me at [email protected]

    Is there a query variable that corresponds to the Category?

    What would fit my needs awesomely would be the ability to feed a category to the tribe_calendar_grid() function. I have modified this function to target a specific month with set_query_var( 'eventDate', '2012-05' );

    So, is there a query variable that corresponds to the Category or another way to accomplish this?

    I’m not sure about this. Tell me what your adapted function you have above in your statement. Also what would you like this function to do on category. You probably could adapt my code into a function. Just instead of putting it in a select box it would actually go to the correct page indicating the category. Let me know if you need some help.

    I should have forked a new topic, but here goes.

    Original Function

    function tribe_calendar_grid()  {
      set_query_var( 'eventDisplay', 'bydate' );
      load_template( TribeEventsTemplates::getTemplateHierarchy('table') );
    }

    Modified to target a year/month

    function tribe_calendar_grid($Yr-Month)  {
      set_query_var( 'eventDate', $Yr-Month );
      load_template( TribeEventsTemplates::getTemplateHierarchy('table') );
    }

    Calling with ‘2012-06’ produces the calender without any controls populated with events for that month.

    Basically all I want to do is embed a calendar or target a calendar page that displays a category. More than one filter would be ideal, so I could produce a calendar specific to a region and an event category.

Viewing 15 replies - 1 through 15 (of 21 total)
  • The topic ‘[Plugin: The Events Calendar] List All Categories, Get Next Event Thumbnail’ is closed to new replies.