EE->config->item('site_url'); $url_title = "who-rules-the-internet"; $html_generation = ""; function unixToMySQL($timestamp) // return date from EE Unix Timestamp { return date('d/m/Y', $timestamp); } function unixToMySQLYear($timestamp) // return only year date from EE Unix Timestamp { return date('Y', $timestamp); } // QUERY TO GET ENTRY ID $query="SELECT entry_id FROM exp_channel_titles WHERE url_title = '$url_title'"; /* field_id_80 = Main body content */ $results = $this->EE->db->query($query); if ($results->num_rows() > 0) { foreach($results->result_array() as $row) { $entry_id = $row['entry_id']; } // end for each } // end this query //echo "entry id is ".$entry_id; // QUERY TO GET NEWS CONTENT $query="SELECT t.entry_id, t.channel_id, t.forum_topic_id, t.author_id, t.ip_address, t.title, t.url_title, t.status, t.dst_enabled, t.view_count_one, t.view_count_two, t.view_count_three, t.view_count_four, t.allow_comments, t.comment_expiration_date, t.sticky, t.entry_date, t.year, t.month, t.day, t.edit_date, t.expiration_date, t.recent_comment_date, t.comment_total, t.site_id as entry_site_id, w.channel_title, w.channel_name, w.channel_url, w.comment_url, w.comment_moderate, w.channel_html_formatting, w.channel_allow_img_urls, w.channel_auto_link_urls, w.comment_system_enabled, wd.* FROM exp_channel_titles AS t LEFT JOIN exp_channels AS w ON t.channel_id = w.channel_id LEFT JOIN exp_channel_data AS wd ON t.entry_id = wd.entry_id WHERE t.entry_id IN ($entry_id) ORDER BY t.sticky desc, t.entry_date desc, t.entry_id desc"; /* field_id_80 = Main body content */ $results = $this->EE->db->query($query); if ($results->num_rows() > 0) { foreach($results->result_array() as $row) { $title = $row['title']; $events_content = $row['field_id_21']; $events_content_two = $row['field_id_46']; $entry_date = unixToMySQL($row['entry_date']); $html_generation .= '

'.$title.'

'; } // end for each } // end this query // QUERY TO GET NEWS CATEGORIES $query="SELECT c.cat_name, c.cat_url_title, c.cat_id, c.cat_image, c.cat_description, c.parent_id, p.cat_id, p.entry_id, c.group_id , cg.field_html_formatting, fd.* FROM (exp_categories AS c, exp_category_posts AS p) LEFT JOIN exp_category_field_data AS fd ON fd.cat_id = c.cat_id LEFT JOIN exp_category_groups AS cg ON cg.group_id = c.group_id WHERE c.cat_id = p.cat_id AND p.entry_id IN ('$entry_id') ORDER BY c.group_id, c.parent_id, c.cat_order "; $results = $this->EE->db->query($query); if ($results->num_rows() > 0) { $html_generation .= '

'.$entry_date.' ('; $i=1; $total = $results->num_rows(); foreach($results->result_array() as $row) { $cat_name = $row['cat_name']; $html_generation .= $cat_name; if ($i == $total) { $html_generation .= ''; } else { $html_generation .= ', '; } $i++; } // end for each $html_generation .= ')

'; } // end this query $html_generation .= $events_content; if ($events_content_two != "") { $html_generation .= '
'.$events_content_two; } // NOW WE JUST NEED TO GET THE RELATED BARRISTERS TO THIS NEWS // FIRST QUERY TO GET CLERKS STUFF - Playa Relationship $query="SELECT DISTINCT ( rel.child_entry_id ) AS entry_id FROM exp_playa_relationships rel WHERE rel.parent_entry_id = $entry_id ORDER BY rel.rel_order"; $results = $this->EE->db->query($query); if ($results->num_rows() > 0) { $entry_ids = ''; foreach($results->result_array() as $row) { $entry_ids .= "'".$row['entry_id']."'".', '; } // end for each } // end this query $entry_ids = substr($entry_ids, 0, -2); $query="SELECT t.entry_id, t.channel_id, t.forum_topic_id, t.author_id, t.ip_address, t.title, t.url_title, t.status, t.dst_enabled, t.view_count_one, t.view_count_two, t.view_count_three, t.view_count_four, t.allow_comments, t.comment_expiration_date, t.sticky, t.entry_date, t.year, t.month, t.day, t.edit_date, t.expiration_date, t.recent_comment_date, t.comment_total, t.site_id as entry_site_id, w.channel_title, w.channel_name, w.channel_url, w.comment_url, w.comment_moderate, w.channel_html_formatting, w.channel_allow_img_urls, w.channel_auto_link_urls, w.comment_system_enabled, m.username, m.email, m.url, m.screen_name, m.location, m.occupation, m.interests, m.aol_im, m.yahoo_im, m.msn_im, m.icq, m.signature, m.sig_img_filename, m.sig_img_width, m.sig_img_height, m.avatar_filename, m.avatar_width, m.avatar_height, m.photo_filename, m.photo_width, m.photo_height, m.group_id, m.member_id, m.bday_d, m.bday_m, m.bday_y, m.bio, md.*, wd.* FROM exp_channel_titles AS t LEFT JOIN exp_channels AS w ON t.channel_id = w.channel_id LEFT JOIN exp_channel_data AS wd ON t.entry_id = wd.entry_id LEFT JOIN exp_members AS m ON m.member_id = t.author_id LEFT JOIN exp_member_data AS md ON md.member_id = m.member_id WHERE t.entry_id IN ($entry_ids) AND channel_title = 'barristers'"; $results = $this->EE->db->query($query); if ($results->num_rows() > 0) { $html_generation .= '

Related Barristers

'; foreach($results->result_array() as $row) { $title = $row['title']; $html_generation .= '

• '.$title.'

'; } // end for each } // end this query $styles=' '; $the_html = $styles.$html_generation; $action = "download"; //echo $the_html; require_once('brick-generate-pdf.php'); ?>