Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter switchskier

    (@switchskier)

    @agelonwl Cool! Thanks

    Thread Starter switchskier

    (@switchskier)

    For anyone interested in similar events, this is how I did it. Suggestions welcome.

    if (class_exists('EM_Events')) {
    	$currentid = $EM_Event->id; //get and store the current event id
    	$cats = $EM_Event->get_categories(); //get the categories for the current event
    	$cat_ids = $cats->get_ids(); //get the ids for the categories of the current event
    	$cat_ids_strg = implode(',', $cat_ids); //make a comma seperated string of category ids
    
    	//use categories to find similar events
    	$sim_events = EM_Events::get(array('limit'=>9,'category'=>$cat_ids_strg,'orderby'=>'start_date')); //build an array of up to 9 events that are similar to the current event
    	$sim_events_ids = array();
    	foreach ($sim_events as $EM_Event) {
    		$sim_events_ids[] = $EM_Event->id; //step thru the similar events and pull out just the event ids
    	}
    	$adj_sim_events_ids = array();
    	foreach ($sim_events_ids as $key => $value) {
    		if ($value != $currentid) { //step thru the similar events ids and pull out the current event id
    			$adj_sim_events_ids[] = $value;
    		}
    	}
    	$adj_sim_events_ids_strg = implode(',', $adj_sim_events_ids); //make a comma seperated string of adjusted category ids
    	echo EM_Events::output( array('limit'=>8,'event'=>$adj_sim_events_ids_strg,'orderby'=>'start_date') ); //output only the adjusted similar event ids
    }
    Thread Starter switchskier

    (@switchskier)

    My plan is to get the current event id and categories, then do an event search using only those categories, output search result event ids to an array, test each id in the array to see if it is the same as the current id, if the id is different build a string of comma separated ids, then use:
    EM_Events::output(array('event'=>'MY-CREATED-ID-STRING')

    I am having trouble pulling the category id’s from the current event. Please help.

Viewing 3 replies - 1 through 3 (of 3 total)