function shcaa_list_events($eventtag = '', $groupname = '')
{
    // attempt to get cached request
    if (isset($groupname) && !empty($groupname)) {
        $transient_key = "_shcaa_events_feed_" . $groupname;
    } else {
        $transient_key = "_shcaa_events_feed_all";
    }
    // If cached (transient) data are used, output an HTML
    // comment indicating such
    $cached = get_transient($transient_key);
    if (false !== $cached) {
        $myevents = $cached;
    } else {
        // create array of the events filtered by the args and include the tags
        $args = array();
        //$args['group_types'] = 'Hope';
        //$args['include_addresses'] = 'true';
        $the_city = new TheCity('theCityUsername');
        if (isset($groupname) && !empty($groupname)) {
            $the_city->set_group_nickname($groupname);
        }
        $events = $the_city->events(50);
        $event_titles = $events->titles();
        $myevents = array();
        $i = 0;
        foreach ($event_titles as $indx => $eve) {
            // get the object
            $rawevent = $events->select($indx);
            // get the body
            $event = accessProtected($rawevent, 'data');
            //print_r('<pre style="padding: 10px; border: 1px solid #000; font-size: 11px; margin: 10px">'); print_r( $event ); print_r('</pre>');
            // unique id
            $myevents[$i]['eve_id'] = $event->euid;
            // starting
            $myevents[$i]['starting_at'] = $event->starting_at;
            // ending
            $myevents[$i]['ending_at'] = $event->ending_at;
            // title
            $myevents[$i]['title'] = $event->title;
            // event_items
            $myevents[$i]['event_items'] = $event->event_items;
            // array
            //body
            $myevents[$i]['body'] = $event->body;
            // shorturl
            $myevents[$i]['short_url'] = $event->short_url;
            $i++;
        }
        // end foreach
        //print_r('<pre style="padding: 10px; border: 1px solid #000; font-size: 12px;  margin: 10px">'); print_r( $event ); print_r('</pre>');
        set_transient($transient_key, $myevents, 60 * 60 * 1);
    }
    // end if not cached
    // events output
    if (!isset($myevents) || empty($myevents)) {
        return;
    }
    // find equipping classess and add extra date modifications
    $myevents = add_event_date_info($myevents);
    $output = '<ul class="eventlist">';
    $cnt = 0;
    //print_r('<pre style="padding: 10px; border: 1px solid #000; font-size: 11px; margin: 10px">'); print_r( $myevents ); print_r('</pre>');
    $dupcheck = array();
    foreach ($myevents as $myeve) {
        $eve_id = $myeve['eve_id'];
        //$image = $myeve['image'];
        $title = trim($myeve['title']);
        // set a virtual event category by detecting substring in the title
        $tag = 'General';
        if (strpos($title, 'Equipping Class') !== false) {
            $tag = 'Equipping Class';
        }
        if (strpos($title, 'Sunday Morning Worship') !== false) {
            $tag = 'Sunday Morning Worship';
        }
        if (!isset($eventtag) || empty($eventtag) || isset($eventtag) && $eventtag == $tag) {
            // if(!in_array($title,$dupcheck)) {   // turned off the dupcheck feature for all events
            $starting_at = $myeve['starting_at'];
            $ending_at = $myeve['ending_at'];
            $dateinfo = isset($myeve['dateinfo']) && !empty($myeve['dateinfo']) ? $myeve['dateinfo'] : '';
            $event_items = $myeve['event_items'];
            // array - may contain images??
            $body = $myeve['body'];
            $short_url = $myeve['short_url'];
            // dates
            if (isset($starting_at) && !empty($starting_at)) {
                if ($tag == 'Equipping Class' || $tag == 'Sunday Morning Worship') {
                    $dates = datetransmog($starting_at, $ending_at, $dateinfo, true);
                } else {
                    $dates = datetransmog($starting_at, $ending_at);
                }
            }
            // if this is a class
            if ($tag == 'Equipping Class') {
                if (!in_array($title, $dupcheck)) {
                    $stitle = str_replace('| Equipping Class', '', $title);
                    $output .= '<li class="event eclass">';
                    $output .= '<table class="blanktable">';
                    $output .= '<tr>';
                    $output .= '<td class="month">' . $dates['month'] . '</td>';
                    $output .= '<td class="title"><h3 class="eve-title">' . $stitle . '</h3></td>';
                    $output .= '</tr>';
                    $output .= '<tr>';
                    $output .= '<td class="datelabel">Dates:</td>';
                    $output .= '<td class="dates"><div class="eve-days">' . $dates['days'] . '</div></td>';
                    $output .= '</tr>';
                    $output .= '<tr>';
                    $output .= '<td class="timelabel">Time:</td>';
                    $output .= '<td class="time"><div class="eve-time">' . $dates['time'] . '</div></td>';
                    $output .= '</tr>';
                    $output .= '</table>';
                    // description
                    if (isset($body) && !empty($body)) {
                        $output .= '<div class="eve-description">' . $body . '</div>';
                    }
                    // link
                    if (isset($short_url) && !empty($short_url)) {
                        $output .= '<a href="' . $short_url . '" target="_blank" class="eve-link button">Learn More and Register</a>';
                    }
                    $output .= '</li>';
                }
            } else {
                $output .= '<li class="event">';
                // name
                if (isset($title) && !empty($title)) {
                    $output .= '<h3 class="eve-title">' . $title . '</h3>';
                }
                // dates
                if (isset($dates['month']) && !empty($dates['month'])) {
                    $output .= '<div class="eve-month">' . $dates['month'] . '</div>';
                }
                if (isset($dates['days']) && !empty($dates['days'])) {
                    $output .= '<div class="eve-days">' . $dates['days'] . '</div>';
                }
                if (isset($dates['time']) && !empty($dates['time'])) {
                    $output .= '<div class="eve-dates">' . $dates['time'] . '</div>';
                }
                // description
                if (isset($body) && !empty($body)) {
                    $output .= '<div class="eve-description">' . $body . '</div>';
                }
                // link
                if (isset($short_url) && !empty($short_url)) {
                    $output .= '<a href="' . $short_url . '" target="_blank" class="eve-link button">Learn More</a>';
                }
                $output .= '</li>';
            }
            // end if
            // } // end if dupcheck
        }
        // end if in tag
        $dupcheck[] = $title;
    }
    // end foreach
    $output .= '</ul>';
    return $output;
}
function shcaa_list_testimonies()
{
    // attempt to get cached request
    $transient_key = "_shcaa_testimonies_feed";
    // If cached (transient) data are used, output an HTML
    // comment indicating such
    $cached = get_transient($transient_key);
    //if ( false !== $cached ) {
    //	$mytestimonies = $cached;
    //} else {
    // create array of the testimonies filtered by the args and include the tags
    $args = array();
    //$args['group_types'] = 'Hope';
    //$args['include_addresses'] = 'true';
    $the_city = new TheCity('hitc');
    $topics = $the_city->topics()->titles();
    print_r('<pre style="padding: 10px; border: 1px solid #000; margin: 10px">');
    print_r($topics);
    print_r('</pre>');
    $mytestimonies = array();
    $i = 0;
    foreach ($topics as $indx => $top) {
        // get the object
        $rawtopic = $topics->select($indx);
        // get the body
        $topic = accessProtected($rawtopic, 'data');
        // starting
        $mytestimonies[$i]['starting_at'] = $topic->starting_at;
        // ending
        $mytestimonies[$i]['ending_at'] = $topic->ending_at;
        // title
        $mytestimonies[$i]['title'] = $topic->title;
        // topic_items
        $mytestimonies[$i]['topic_items'] = $topic->topic_items;
        // array
        //body
        $mytestimonies[$i]['body'] = $topic->body;
        // shorturl
        $mytestimonies[$i]['short_url'] = $topic->short_url;
        // Address Items
        $mytestimonies[$i]['street'] = $topic->addresses->street;
        $mytestimonies[$i]['street2'] = $topic->addresses->street2;
        $mytestimonies[$i]['city'] = $topic->addresses->city;
        $mytestimonies[$i]['state'] = $topic->addresses->state;
        $mytestimonies[$i]['zipcode'] = $topic->addresses->zipcode;
        $mytestimonies[$i]['location_type'] = $topic->addresses->location_type;
        $mytestimonies[$i]['latitude'] = $topic->addresses->latitude;
        $mytestimonies[$i]['longitude'] = $topic->addresses->longitude;
        $i++;
    }
    // end foreach
    print_r('<pre style="padding: 10px; border: 1px solid #000; margin: 10px">');
    print_r($mytestimonies);
    print_r('</pre>');
    //set_transient( $transient_key, $mytestimonies, 60*60*12 );
    //} // end if not cached
    // testimonies output
    $output = '<ul class="topiclist">';
    $cnt = 0;
    //print_r('<pre style="padding: 10px; border: 1px solid #000; margin: 10px">'); print_r( $mytestimonies ); print_r('</pre>');
    foreach ($mytestimonies as $myeve) {
        $top_id = $myeve['eve_id'];
        $parentid = $myeve['parentid'];
        $image = $myeve['image'];
        $name = $myeve['name'];
        $description = $myeve['description'];
        $neighborhood = $myeve['neighborhood'];
        $invite = $myeve['invite'];
        $cityurl = $myeve['cityurl'];
        // Get Tags
        $dtags = $myeve['mytags'];
        if (is_array($dtags) && !empty($dtags)) {
            //print_r('<pre style="padding: 10px; border: 1px solid #000; margin: 10px">'); print_r( $dtags ); print_r('</pre>');
            $mytags = '<div class="eve-tags"';
            foreach ($dtags as $dtag) {
                if (is_array($dtag)) {
                    //foreach ($tag as $el){
                    $mytags .= '<span> | ' . $dtag['name'] . ' | </span>';
                    //} // end inner foreach
                }
                // end if
            }
            // end foreach
            $mytags .= '</div>';
        } else {
            $mytags = '';
        }
        $output .= '<li class="topic">';
        // image
        if (isset($image) && !empty($image)) {
            $output .= '<div class="eve-image"><img src="' . $image . '" alt="' . $name . '" title="' . $name . '" /></div>';
        }
        // name
        if (isset($name) && !empty($name)) {
            $output .= '<div class="eve-name">' . $name . '</div>';
        }
        // description
        if (isset($description) && !empty($description)) {
            $output .= '<div class="eve-description">' . $description . '</div>';
        }
        // Invitation
        if (isset($invite) && !empty($invite)) {
            $output .= '<div class="eve-invite">' . $invite . '</div>';
        }
        // neighborhood
        if (isset($neighborhood) && !empty($neighborhood)) {
            $output .= '<div class="eve-neighborhood">' . $neighborhood . '</div>';
        }
        // Location
        $output .= '<h3>Location</h3>';
        // location name
        if (isset($add_name) && !empty($add_name)) {
            $output .= '<div class="eve-add-name">' . $add_name . '</div>';
        }
        $output .= '<div class="eve-add">';
        // location street
        if (isset($add_street) && !empty($add_street)) {
            $output .= '<div class="eve-add-street">' . $add_street . ', </div>';
        }
        // location street 2
        if (isset($add_street2) && !empty($add_street2)) {
            $output .= ' <div class="eve-add-street2">' . $add_street2 . ', </div> ';
        }
        // location city
        if (isset($add_city) && !empty($add_city)) {
            $output .= ' <div class="eve-add-city">' . $add_city . ' </div> ';
        }
        // location state
        if (isset($add_state) && !empty($add_state)) {
            $output .= ' <div class="eve-add-state">' . $add_state . ', </div> ';
        }
        // location zip
        if (isset($add_zipcode) && !empty($add_zipcode)) {
            $output .= ' <div class="eve-add-zipcode">' . $add_zipcode . ' </div> ';
        }
        // end address box
        $output .= '</div>';
        // testimonies tags
        if (isset($mytags) && !empty($mytags)) {
            $output .= $mytags;
        }
        // location coords
        if (isset($add_longitude) && !empty($add_longitude) && (isset($add_latitude) && !empty($add_latitude))) {
            $output .= '<div class="eve-add-coords">' . $add_longitude . ',' . $add_latitude . ', </div>';
        }
        $output .= '</li>';
    }
    $output .= '</ul>';
    return $output;
}