CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • Linking to an Event Type / Category
Pages: [1]

Author Topic: Linking to an Event Type / Category  (Read 578 times)

wdwgrna

  • I’m new here
  • *
  • Posts: 3
  • Karma: 0
  • CiviCRM version: 3.3.5
  • CMS version: Joomla 1.5.21
  • MySQL version: 5.2.x
  • PHP version: 5.2.x
Linking to an Event Type / Category
February 24, 2011, 07:06:23 am
In Joomla, I need to create a custom module with with text links that link to all events in a specific "event type" or "category. I can't figure out that link to add. It needs to just pull any "event type" that hasn't expired. I have downloaded and installed the Joomla Events listing module, but it doesn't let me do it like this all in one module.

qjensen

  • I post frequently
  • ***
  • Posts: 141
  • Karma: 11
    • Scaled Solutions
  • CiviCRM version: 4.5
  • CMS version: Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Linking to an Event Type / Category
February 25, 2011, 04:12:02 pm
I am not a Joomla dev, but the civi code to do this should be the same.

In your module, you will need a function to get a list of events by their type:

Code: [Select]
function getEventByType($type_id){
  $params = array(
                  'event_type_id' =>$type_id
                 );
    $events = civicrm_event_get( $params );
    if ( civicrm_error( $events)) {
        return $events['error_message'];
    }
    else {
    $links = array();
            //return only events that have a start date greater than today
            foreach($events as &$event) {
        $eventstart = CRM_Utils_Date::processDate($event['event_start_date']);
        $today = CRM_Utils_Date::processDate(date( 'YmdHis'));
        if($eventstart > $today) {
            $links[] = CRM_Utils_System::url("civicrm/event/register","reset=1&id=".$event['id']);
        }
    return $links
        }
    }
    return null;
}

I haven't tested this and I bet my date math is a little off but the code should be pretty close to what you need. API docs for this are at http://wiki.civicrm.org/confluence/display/CRMDOC33/Event+APIs.
« Last Edit: February 26, 2011, 03:47:27 am by qjensen »
Quint Jensen
Web Developer
Scaled Solutions
--" Remove the 'I want you to like me' notes from your forehead and place them where they truly will do the most good -- on your mirror!" Author Unknown

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • Linking to an Event Type / Category

This forum was archived on 2017-11-26.