Events Calendar Pro & SiteOrigin's Page Builder Widget

Home Forums Calendar Products Events Calendar PRO Events Calendar Pro & SiteOrigin's Page Builder Widget

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #549920
    aling
    Participant

    Hello!
    Need some help. Hope someone can help me.

    I’m currently using SiteOrigin’s theme called Vantage and using their page builder widget for the homepage.

    I have a widget I’m using called “Events Featured Venue” and this widget uses this file: /views/pros/widgets/venue-widget.php

    I was able to modify that file so that it would display thumbnail images vs the title and schedule info.

    However, now I want to also tweak it a bit more based on my “additional fields” that I created.

    One of the fields is “Show on Homepage?” with a radio button of yes or no.

    I would like for venue-widget.php to not only display the next upcoming 4 events but I want it to filter it based on if “Show on Homepage” is selected with yes.

    I can do that for our other sites because I’m using BxSlider and its just a php query but I’m not sure how to do that with the existing code on venue-widget.php

    This is what I use on my other sites:

    
    <?php
    	$query_str = "SELECT distinct wposts.ID FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id  AND wpostmeta.meta_key = '_EventStartDate' 
    	AND wposts.post_type = 'tribe_events' ORDER BY wpostmeta.meta_value ASC ";
    	$posts = $wpdb->get_results( $query_str );
    	foreach($posts as $post){
    		setup_postdata($post);
    		$id=get_the_ID();
    		$linkr=get_post_meta($id,'_ecp_custom_3',true);
    		
    		date_default_timezone_set('America/Los_Angeles');
    		$todayDate = date("Y-m-d H:i:s");
    		$eventDate=get_post_meta($id,'_EventEndDate', "Y-m-d H:i:s");
    		
    		if ((strtolower($linkr)=='yes') && ($eventDate >= $todayDate)) {
    			$link=get_permalink($id);
    			echo "<li>";
    			the_post_thumbnail();
    			echo "</li>";
    		}
    	}
    ?>
    
    

    This is what my venue-widget.php file looks like:

    
    <div class="tribe-venue-widget-wrapper">
    	<ul>
    	<?php while ( $events->have_posts() ): ?>
            <?php $events->the_post(); ?>
            < li >
                <?php the_post_thumbnail('medium'); ?>
            < /li >
        <?php endwhile;	?>
        <div style="clear:both;">
        </ul>
    </div>
    
    #557868
    Barry
    Member

    Hi!

    You could add a test in your custom venue widget template to check if that custom field is set and, if so, skip over it. The downside to that approach of course is that it won’t pull in an additional event to replace the one that is skipped.

    It would be possible to modify the query before the template is rendered but it would be a fairly advanced customization to do so and not one we can really go into here on the forum, unfortunately.

    Perhaps though a middle ground could be as follows:

    • Increase the number of events listed by the widget so it returns more events than you need (ie, use the maximum setting of 10)
    • Customize your template so that it:
      • Skips events that have been flagged with your custom field
      • Exits the loop once four events have been displayed

    Not a perfect solution and it may not work in your case, but I thought it was worth mentioning as a “quick and dirty” alternative.

    I hope that helps or at least gives you a couple of ideas you can explore πŸ™‚

    #560669
    aling
    Participant

    Hi Barry-
    Thanks for getting back to me. I actually want to be able to see if the custom field is set, if it is, then I want that event to display on the homepage (which is the first set of code above that I’m using on our other site not in the venue-widget.php).
    I guess my problem is not knowing how to write that into the 2nd set of code I have above because I don’t understand what $events->have_posts() is. Like I understand while events have post but how do I incorporate an if statement within a while loop? Or is that beyond the scope?

    #560740
    aling
    Participant

    This is what I came up with but it’s still not right:

    
    <div class="tribe-venue-widget-wrapper">
    	
      <?php while ( $events->have_posts() ): ?> <?php $events->the_post(); foreach($events as $event){ setup_postdata($event); $id=get_the_ID(); $showOnHomepage=get_post_meta($id,'_ecp_custom_4',true); date_default_timezone_set('America/Los_Angeles'); $todayDate = date("Y-m-d H:i:s"); $eventDate=get_post_meta($id,'_EventEndDate', "Y-m-d H:i:s"); if (($showOnHomepage == 'Yes') && ($eventDate >= $todayDate)) { $link=get_permalink($id); echo "
    • "; the_post_thumbnail('medium'); echo "
    • "; } } ?> <?php endwhile; ?> <div style="clear:both"></div>
    </div>
    #579424
    Barry
    Member

    I think some of your code may have been stripped out, unfortunately, particularly within your echo statements. The forum is unfortunately not too great when it comes to sharing code and so it’s often best to share snippets via Pastebin, Gist or some similar service.

    This is what I came up with but it’s still not right

    So what are the sticking points here? Please also note that – though we’re happy to help if we can – this sort of customization is really beyond what we’d normally assist with. If you can provide a little more detail as to why that solution isn’t working for you, though, I might be able to offer up a few ideas.

    One final other thought is that you could build a custom widget of your own to handle this – that may be cleaner than trying to bend the existing widget to your will πŸ™‚

    #579509
    aling
    Participant

    Well the existing widget is perfectly fine, however, I would like to be able to select which event will display based on whether the additional field I set is Yes or No.

    I guess I will just have to play around with it. I can write it out no problem if I made my own homepage template but I’m using Site Origin’s homepage builder widget stuff and I was trying to make things a little easier for the user who will be updating the site vs them having to deal with html code and possibly messing up the site.

    #580273
    Barry
    Member

    OK – and so what is actually going wrong with the code you shared a couple of replies back? It broadly looks like it should work (so long as you have enough events coming in to the widget to retain and display some events and skip others, at least).

    #580279
    aling
    Participant

    I was able to get get help via stackoverflow.com. Someone rewrote my code and it’s working fine now.

    #580288
    Barry
    Member

    Excellent!

    I’ll go ahead and close this thread in that case but if you need help with anything else please don’t hesitate to create a new thread and one of the team will be only too happy to help πŸ™‚

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Events Calendar Pro & SiteOrigin's Page Builder Widget’ is closed to new replies.