Should I make a custom widget for this?
-
Hello
i am trying to integrate the events manager to display a 5 day schedule on a specific part of the front page of the site i’m working on. I am working on a child theme of a commercial template that is bootstrapped.
the code i have here for the page template works (see attached code), but it is not flexible at all. i’d like to take the 5 day part anywhere someone would like to put it on the front page, mainly for flexibility for various content.
i’m thinking that this might work as a widget, but i’m not really sure how to set that up exactly….any ideas? or would there be an easier way to do this? one idea i was thinking about was installing a php shortcode snippet plugin and then using that and just using a shortcode to put anywhere on the site…that didn’t work ??
if i make this a widget, what is the setup/structure in a child theme directory using the events manager plugin? and how do you set that up in the functions.php file?
thank you for any help!
<?php /*template name: Home */ get_header(); ?> <?php nectar_page_header($post->ID); ?> <div class="container-wrap"> <div class="container main-content"> <div class="row"> <?php //buddypress global $bp; if($bp && !bp_is_blog_page()) echo '<h1>' . get_the_title() . '</h1>'; ?> <?php if(have_posts()) : while(have_posts()) : the_post(); ?> <!-- START ---------------------------------------------------> <div class="row"> <!-- // 5-day --> <!-- TODAY FOR EVENTS CALENDAR --> <div > <? $today = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d"), date("Y"))); $dispMonth = date("F", mktime(0, 0, 0, date("m"), date("d"), date("Y"))); $dispDay = date("d", mktime(0, 0, 0, date("m"), date("d"), date("Y"))); $eventID = EM_Events::output(array(scope=> $today, 'limit'=>1, 'format'=>'#_EVENTPOSTID')); $day = EM_Events::output(array(scope=> $today, 'limit'=>1, 'format'=>' <div class="today"> <div class="today-content"> <div class="date"> <h4>'.$dispMonth.'</h4> <h1>'.$dispDay.'</h1> </div> <h2><a href="#_EVENTURL">#_EVENTNAME</a></h2> #_EVENTEXCERPT ')); if ($day == "No Events") { ?> <div class="today"> <div class="today-content"> <div class="date"> <h4><?=$dispMonth?></h4> <h1><?=$dispDay?></h1> </div> <h2><a href="service-post.html">No Service</a></h2> Check our schedule for our next service. <? } else { echo $day; ?> <div class="menu-today"> <h5>Today's Menu:</h5> <div class="menu-today"> <table cellspacing="0"> <? $menu = get_post_meta($eventID, 'menu'); $menuitems = explode(" ",$menu[0]); $args = array( 'post_type'=> 'food', 'order' => 'ASC', 'posts_per_page' => 300 ); query_posts( $args ); ?> <tr><th>Menu item</th><th>Price</th></tr> <? while (have_posts()) : the_post(); $menu_item_slug = basename(get_permalink()); $price = get_post_meta(get_the_ID(), 'foodprice'); if (in_array($menu_item_slug, $menuitems)) { ?> <tr><td><a href="<?=the_permalink();?>"><?=the_title();?> </a></td><td><?=$price[0]?></td></tr> <? } endwhile;?> </table> </div> </div><!-- end menu-today --> <? } ?> </div><!-- six columns alpha --> </div> <!-- tabs1-today --> </div><!-- end today --> <div class="six columns omega"> <div class="map"> <div class="embed-container"> <? if ($day == "No Events") { ?> <img class="noservice-map" src="<?bloginfo('template_url')?>/images/noservice-map.jpg"> <? } else { echo EM_Events::output(array(scope=> $today, 'limit'=>1, format=>'#_LOCATIONMAP')); } ?> </div> </div><!-- end map --> </div> </div><!-- end panel container --> </div><!-- end twelve --> <div> <header><h2>5 Day Schedule</h2></header> <div id="fiveday"> <? $i=0; while ($i < 5) { $thisday = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d")+$i, date("Y"))); $dispMonth = date("F", mktime(0, 0, 0, date("m"), date("d")+$i, date("Y"))); $dispDay = date("d", mktime(0, 0, 0, date("m"), date("d")+$i, date("Y"))); $day = EM_Events::output(array(scope=> $thisday, 'limit'=>1)); if ($day == "No Events") {?> <div class="day off"> <div class="corner"></div> <div class="date"> <h2><?=$dispMonth?></h2> <h1><?=$dispDay?></h1> </div> <div class="description"> <h3><a href="">No service</a></h3> <p>Check our schedule for our next service. We’ll see you out there soon!</p> </div> </div> <?} else { echo $day; //echos html from the events plugin - can change in event plug settings } $i++; } ?> </div><!-- fiveday --> </div><!-- end twelve --> <!-- END 5day --> <?php the_content(); ?> <?php endwhile; endif; ?> </div><!--/row--> <!-- END ---------------------------------------------------> </div><!--/container--> </div> <?php get_footer(); ?>
- The topic ‘Should I make a custom widget for this?’ is closed to new replies.