Support

Home Forums Event Espresso Premium People to PDF

People to PDF

Posted: September 11, 2018 at 6:58 am

Viewing 5 reply threads


motio

September 11, 2018 at 6:58 am

Hi

I am trying to do an PDF export via the DK PDF Plugin. It’s almost done but I can’t load the People View helper to get the data from the instructor of the event.
I’ve tried the following…

EE_Registry::instance()->load_helper( ‘People_View’ );
$people = EEH_People_View::get_people_for_event();

and got the error message:

An EE_Error exception was thrown! code: EE_Registry – _require_file – 1131
“The helper file EEH_People_View could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct:

How do I get the permission or can I get the information in an other way?


Josh

  • Support Staff

September 11, 2018 at 10:08 am

Hi,

The People View helper class is intended to be used only on the front end of the site, so it’s not ready to load when doing a PDF export. What you can do instead is build your own custom function from the contents of the _get_rel_objects() method, which basically does the same thing as the helper method you tried to call. Here’s a link to its source:
https://github.com/eventespresso/eea-people-addon/blob/master/core/helpers/EEH_People_View.helper.php#L113


motio

September 11, 2018 at 11:03 am

I was wondering, because the Venue_View and the Event_View helper both worked in the export.

Is there an other way to get to the information? I would only need the name of the person for that event.
Can get it through an sql query? I only found the esp_people_to_post table in the database.


Josh

  • Support Staff

September 11, 2018 at 11:37 am

I gave you another way to get the information. If you’d prefer to write a direct SQL you’re welcome to write one, but the helper method code I shared with you will do the SQL query for you.


motio

September 12, 2018 at 1:24 am

Hey Josh,

I understand, that a custom function would be the best solution but I have the following Error and can’t find a solution.

Uncaught Error: Class 'EEM_Person_Post' not found

Could you give me a hint what I have to edit in the custom function or what additional table I have to use for the sql query?

function person_objects($obj_id = 0, $primary_obj_type = 'Person')
	    {
		$kurs_postid = $_GET["kurs_postid"];

	        $objects = array();
	        if (empty($obj_id)) {
	            global $post;
	            $obj_id = $post instanceof WP_Post ? $kurs_postid : $obj_id;
	        }
	        // still empty? return empty array
	        if (empty($obj_id)) {
	            return array();
	        }
	        if ($primary_obj_type !=  'Person') {
	            $where = array( 'PER_ID' => $obj_id, 'OBJ_type' => $primary_obj_type );
	            $query = array( $where );
	        } else {
	            $where = array( 'OBJ_ID' => $obj_id );
	            $query = array( $where, 'order_by' => array( 'PER_OBJ_order' => 'ASC' ) );
	        }
	        $object_items = EEM_Person_Post::instance()->get_all($query);
	        $term_name_cache = array();
	        if (method_exists(EEM_Event::instance(), 'public_event_stati')) {
	            $public_event_stati = EEM_Event::instance()->public_event_stati();
	        } else {
	            $public_event_stati = get_post_stati(array( 'public' => true ));
	            foreach (EEM_Event::instance()->get_custom_post_statuses() as $custom_post_status) {
	                $public_event_stati[] = strtolower(str_replace(' ', '_', $custom_post_status));
	            }
	        }
	        foreach ($object_items as $object_item) {
	            if (! isset($term_name_cache[ $object_item->get('PT_ID') ])  || ! isset($objects[ $term_name ][ $object_item->ID() ])) {
	                $term_name =  EEM_Term_Taxonomy::instance()->get_one_by_ID($object_item->get('PT_ID'))->get_first_related('Term')->get('name');
	                $related_object = $object_item->get_first_related($primary_obj_type, array( array( 'status' => array(
	                    'IN', apply_filters('FHEE__EEH_People_View__get_rel_objects__public_event_stati', $public_event_stati)
	                ) ) ));
	                if ($related_object instanceof EE_Base_Class) {
	                    $objects[ $term_name ][ $object_item->ID() ] = $related_object;
	                    $term_name_cache[ $object_item->get('PT_ID') ] = $term_name;
	                }
	            }
	        }
	        return $objects;
	    }


motio

September 12, 2018 at 2:33 am

Hey Josh,
I found the error. Thank you a lot for your help. That was the last point that was missing for the pdf.

Viewing 5 reply threads

The support post ‘People to PDF’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso