I would like to have the option to add a widget with a list of just the titles and having the tooltip with the info.
I can setup the feed to dont show anything but the title (no date, time or description), but then I dont have a link either.
I would like to have the option to add a widget with a list of just the titles and having the tooltip with the info.
I can setup the feed to dont show anything but the title (no date, time or description), but then I dont have a link either.
Hello,
I'm afraid this isn't possible currently, but is certainly something I would look into implementing for a future version of the plugin.
Thanks for your feedback!
Ross
RESOLVED:
1. Open /widget/gce-widget.php
2. Add two new "cases" to the SWITCH:
case 'titles':
echo '<div class="gce-widget-list" id="' . $args['widget_id'] . '-container">';
//Output main widget content as list
gce_widget_content_title_list($feed_ids, $title_text);
echo '</div>';
break;
case 'titles-grouped':
echo '<div class="gce-widget-list" id="' . $args['widget_id'] . '-container">';
//Output main widget content as a grouped list
gce_widget_content_title_list($feed_ids, $title_text, true);
echo '</div>';
break;
3. Right before the end, add a new function:
function gce_widget_content_title_list($feed_ids, $title_text, $grouped = false){
//Create new GCE_Parser object, passing array of feed id(s)
$list = new GCE_Parser(explode('-', $feed_ids), $title_text);
//If the feed(s) parsed ok, output the list markup, otherwise output an error message
if(count($list->get_errors()) == 0){
echo $list->get_title_list($grouped);
}else{
printf(__('The following feeds were not parsed successfully: %s. Please check that the feed URLs are correct and that the feeds have public sharing enabled.'), implode(', ', $list->get_errors()));
}
4. Open /inc/gce-parser.php
5. Right before "//Returns the event information markup for the specified event (type = tooltip or list)" add this function:
function get_title_list($grouped = false){
$event_days = $this->get_event_days();
//If event_days is empty, there are no events in the feed(s), so return a message indicating this
if(count((array)$event_days) == 0) return '<p>' . __('There are currently no upcoming events.', GCE_TEXT_DOMAIN) . '</p>';
$today = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
$markup = '<ul class="gce-list">';
foreach($event_days as $key => $event_day){
//If this is a grouped list, add the date title and begin the nested list for this day
if($grouped){
$markup .=
'<li' . ($key == $today ? ' class="gce-today"' : '') . '>' .
'<p class="gce-list-title">' . $this->title . ' ' . date_i18n($event_day[0]->get_feed()->get_date_format(), $key) . '</p>' .
'<ul>';
}
foreach($event_day as $event){
//Create the markup for this event
$markup .=
'<li class="gce-has-events">' .
//If this isn't a grouped list and a date title should be displayed, add the date title
((!$grouped && isset($this->title)) ? '<p class="gce-list-title">' . $this->title . ' ' . date_i18n($event->get_feed()->get_date_format(), $key) . '</p>' : '') .
//Add the event title
'<p class="gce-list-event">' . esc_html($event->get_title()) . '</p> <div class="gce-event-info"> <ul><li>' .
//Add the date to the event
((!$grouped && !isset($this->title)) ? '<p class="gce-tooltip-event">' . $this->title . ' ' . date_i18n($event->get_feed()->get_date_format(), $key) . '</p>' : '') .
$this->get_event_info_markup($event, 'tooltip') .
'</li></ul></div></li>';
}
//If this is a grouped list, close the nested list for this day
if($grouped) $markup .= '</ul></li>';
}
$markup .= '</ul>';
return $markup;
}
6. Add a couple of styles at the bottom of /css/gce-style.css:
.gce-list .gce-has-events .gce-event-info{ /* Event information */
display:none; /* Important! */
}
.gce-widget-list .gce-list .gce-list-event{ /* The event title */
cursor:pointer;
color:#25A;
}
7. Now you will have 2 more options in the widget: "Title List" and "Title List -ordered by date"
I forgot 1 more step:
3a. Look for:
<option value="list-grouped"<?php selected($display_type, 'list-grouped');?>><?php _e('List - grouped by date', GCE_TEXT_DOMAIN); ?></option>
and add this right after:
<option value="titles"<?php selected($display_type, 'titles');?>><?php _e('Title List', GCE_TEXT_DOMAIN); ?></option>
<option value="titles-grouped"<?php selected($display_type, 'titles-grouped');?>><?php _e('Title List - grouped by date', GCE_TEXT_DOMAIN); ?></option>Thanks for posting your solution!
I'm struggling to find time to develop the plugin at the moment, but I'll make a note of this and look into adding it to a future release when I get the chance.
Thanks again!
Ross.
Thanks medinauta for this code. It's exactly what I was looking for. There was one small issue with your code, however - Item 3 is missing the closing bracket. So for others trying this code and getting a white page, use this code (bracket added):
function gce_widget_content_title_list($feed_ids, $title_text, $grouped = false){
//Create new GCE_Parser object, passing array of feed id(s)
$list = new GCE_Parser(explode('-', $feed_ids), $title_text);
//If the feed(s) parsed ok, output the list markup, otherwise output an error message
if(count($list->get_errors()) == 0){
echo $list->get_title_list($grouped);
}else{
printf(__('The following feeds were not parsed successfully: %s. Please check that the feed URLs are correct and that the feeds have public sharing enabled.'), implode(', ', $list->get_errors()));
}
}This topic has been closed to new replies.