Created
March 14, 2011 21:58
-
-
Save fredkelly/869964 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | |
$plugin_info = array( | |
'pi_name' => 'Post Categories', | |
'pi_version' =>'1.0', | |
'pi_author' =>'Fred Kelly', | |
'pi_author_url' => 'http://fredkelly.net/', | |
'pi_description' => 'Returns the post categories how I want them.' | |
//'pi_usage' => Post_categories::usage() | |
); | |
class Post_categories { | |
function Post_categories() | |
{ | |
$this->EE =& get_instance(); | |
// path to category listing (inc. trailing slash) | |
$cat_path = 'journal/category/'; | |
// grab the entry id of the post | |
$entry_id = $this->EE->TMPL->fetch_param('entry_id'); | |
// get the name & url_title from the DB | |
$results = $this->EE->db->query("SELECT cat_name, cat_url_title FROM exp_categories, exp_category_posts WHERE exp_categories.cat_id=exp_category_posts.cat_id AND exp_category_posts.entry_id=" . $entry_id . ' ORDER BY exp_categories.cat_name ASC'); | |
$i = 0; | |
if ($results->num_rows() > 0) | |
{ | |
foreach($results->result_array() as $row) | |
{ | |
$sep = ($results->num_rows()-1==$i ? ' & ' : ', '); | |
$this->return_data .= ($i>0 ? $sep : '') . '<a href="' . $this->EE->functions->create_url($cat_path . $row['cat_url_title']) . '">' . $row['cat_name'] . '</a>'; | |
$i++; | |
} | |
} | |
} | |
} | |
/* End of file pi.post_categories.php */ | |
/* Location: ./system/expressionengine/third_party/post_categories/pi.post_categories.php */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment