• Resolved Handstand

    (@handstand)


    Hi, Is there a way to show the event description on the widget “todays events”? I’ve tried overriding the template file in my child theme, but I think I have the wrong file. Are you able to tell me where to find the file? or how to show the description? Thanks in advance

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Contributor motopress

    (@motopress)

    Hi @handstand,

    You will need to override the following file

    \wp-content\plugins\mp-timetable\templates\theme\widget-upcoming-view.php

    adding the line below:

    <span class="event-description"><?php echo $event->description; ?></span>

    Thread Starter Handstand

    (@handstand)

    Hi,

    Thanks for the code. It works perfectly when I put it in the plugins folder ??

    However, I don’t want to lose the code when I update the plugin. I tried putting it in my theme’s folder, but it doesn’t work. I’m using a child theme of Genesis. Here’s where I put the file with the extra code:
    /wp-content/themes/childtheme/mp-timetable/templates/theme/widget-upcoming-view.php

    Any clues as to why it’s not working in the theme folder?

    Thanks

    Plugin Contributor motopress

    (@motopress)

    Hi @handstand,
    I’m terribly sorry for such a delay. When you override the file of timetable plugin the directory structure should be without /templates/ part:
    /wp-content/themes/childtheme/mp-timetable/theme/widget-upcoming-view.php

    Hi, please I have this same issue. But the description still doesn’t show after adding “<span class=”event-description”><?php echo $event->description; ?></span>“ to the PHP file or am I adding it to the wrong line of code? If so where do I add it in that folder. I’m a bit new to PHP please.

    Plugin Support dimned

    (@dimned)

    Hi @fiezie92,
    Please try to switch the plugin mode from Theme to Developer via TimeTable > Settings. If it is not helpful I’d ask you to desribe what file you edit or whether you override it via child theme and where exactly you placed the line

    <span class=”event-description”><?php echo $event->description; ?></span>

    Hi, I already switched from theme to developer default before and it wasn’t working. That’s why I switched. The screenshot I added is a developer option. The file I edited was the one you mentioned above “ \wp-content\plugins\mp-timetable\templates\theme\widget-upcoming-view.php“. No I didn’t override through a child theme. I wanted to see if I could troubleshoot the issue then create a child theme and copy it over. I’ll send a screenshot of where I placed the line of code or copy the code here.

    This is my full code and where I pasted it

    <?php echo $args['before_widget'];
    
    if (!empty($instance['title'])) {
    	echo $args['before_title'] . $instance['title'] . $args['after_title'];
    }
    
    do_action('mptt_widget_upcoming_before_content', $events);
    
    $time_format = get_option('time_format');
    
    $events_group_by_categories = array();
    
    foreach ($events as $event) {
    	if (!isset($temp[$event->column_id])) {
    		$events_group_by_categories[$event->column_id][] = $event;
    	} else {
    		$events_group_by_categories[$event->column_id][] = $event;
    	}
    }
    
    if (!empty($events)): ?>
    	<?php foreach ($events_group_by_categories as $key_category => $cat_events) { ?>
    		<ul>
    			<?php foreach ($cat_events as $key => $event):
    				$event_class = 'event';
    				?>
    				<li class="<?php echo apply_filters('mptt_widget_upcoming_event_class', $event_class) ?>">
    					<?php
    
    					$disable_url = (bool)$event->post->timetable_disable_url || (bool)$instance['disable_url'];
    					$url = ($instance['custom_url'] != "") ? $instance['custom_url'] : (($event->post->timetable_custom_url != "") ? $event->post->timetable_custom_url : get_permalink($event->event_id));
    
    					if (!$disable_url) { ?>
    					<a href="<?php echo $url ?>" title="<?php echo get_the_title($event->event_id) ?>" class="event-link">
    						<?php }
    						echo get_the_title($event->event_id);
    						if (!$disable_url) { ?>
    					</a><br/>
    				<?php } ?>
    					<span class="post-date">
    				<?php if ($instance['view_settings'] !== 'today' && $instance['view_settings'] !== 'current'): ?><?php echo get_the_title($event->column_id) ?>
    					<br/>
    				<?php endif; ?>
    						<time datetime="<?php echo $event->event_start; ?>" class="timeslot-start"><?php echo date($time_format, strtotime($event->event_start)); ?></time>
    						<?php echo apply_filters('mptt_timeslot_delimiter', ' - '); ?>
    						<time datetime="<?php echo $event->event_end; ?>" class="timeslot-end"><?php echo date($time_format, strtotime($event->event_end)); ?></time>
    				</span>
    				<span class="event-description"><?php echo $event->description; ?></span>
    				</li>
    			<?php endforeach; ?>
    		</ul>
    		<?php
    	}
    else:
    	_e('no events found', 'mp-timetable');
    endif;
    
    do_action('mptt_widget_upcoming_after_content', $events);
    
    echo $args['after_widget'] ?>
    Plugin Support dimned

    (@dimned)

    Hi @fiezie92,
    I’ve tested your code and it worked for me when Theme Mode was active. The path of the file is as follows:

    \wp-content\themes\%active-theme-folder%\mp-timetable\theme\widget-upcoming-view.php

    Make sure you have added description to the timeslots to show it in the widget.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Add description to Widget ‘Todays Events’’ is closed to new replies.