[eluser]lenwood[/eluser]
I figured it out. Somehow it just made sense to me when I sat down at my computer tonight.
I'm calling the category names in two views, a listing of all of my blog entries and on the individual posts. Here's my code:
Listing of all blog entries:
Code:
function list_all_blog_entries()
{
$this->db->select("*, date_format(date_time, '%W, %M %e, %Y') as date", FALSE);
$this->db->order_by('date_time', 'desc');
$this->db->join('post_cat', 'post_cat.entry_id = entries.id');
$this->db->join('categories', 'categories.id = post_cat.cat_id');
$query = $this->db->get('entries');
if($query->num_rows() > 0) {
foreach ($query->result() as $row) {
$this->db->like('entry_id', $row->id);
$row->num_comm = $this->db->count_all_results('comments');
$data[] = $row;
}
}
return $query->result();
}
Single blog post
Code:
function single()
{
$this->db->select("*, date_format(date_time, '%W, %M %e, %Y') as date, date_format(date_time, '%l:%i %p') as time", FALSE);
$this->db->where('post_slug', $this->uri->segment(3));
$this->db->join('post_cat', 'post_cat.entry_id = entries.id');
$this->db->join('categories', 'categories.id = post_cat.cat_id');
$query = $this->db->get('entries');
if($query->num_rows() > 0) {
$row = $query->row_array();
return $row;
}
}
This code works, I'm able to call the category names directly. All feedback on my code is welcome. I'll take this as a sign that there's value in slogging through something that you don't understand, trusting that it will become clear at some point.