It looks like you're new here. If you want to get involved, click one of these buttons!
$category = $CI->uri->segment(2);
$subCategory = $CI->uri->segment(3);***
$CI->load->model('images_to_members_model');
if(!empty($category)):
$CI->load->model('categories_model');
$CI->load->model('sub_categories_model');***
// remember, all categories that have a published value of 'no' will automatically be excluded
$category = $CI->categories_model->find_one_by_name($category);
$members = $category->members($subCategory);***
else:
$CI->load->model('members_model');
// remember, all members that have a published value of 'no' will automatically be excluded
$members = $CI->members_model->find_all();
endif;
?>
<h1><?php if (!empty($category)) : ?> <?=$category->name?> <?php endif; ?></h1>
<?php if(!empty($subCategory)) echo '<h2>' . $subCategory . '</h2>'; ?>
<div style="margin-top: 10px;">
<?php foreach($members as $member): ?>
<div class="member">
<?php $memberId = $member->id; ?>
<img src="<?=img_path() . 'members/' . $member->logo?>" />
<h2 class="member"><?=fuel_edit($member->id, 'Edit: '.$member->title, 'members')?><?=$member->title?></h2>
<p>Address: <?=$member->address?></p>
<p>Phone: <?=$member->phone?></p>
<p>Web site: <a href="http://<?=$member->site?>" target="_blank"><?=$member->site?></a></p>
<p><?=$member->content?></p>
<p>
<ul class="gallery">
<?php
$CI->load->model('member_images_model');
$images = $CI->member_images_model->find_all(array('member_id'=>$memberId), 'id asc');
foreach($images as $img):
$image = img_path() . 'members/' .$img->image;
echo '<li>
<a href="' . $image .'" rel="' . $memberId . '"><img src="' . $image . '" height="100" /></a>
</li>';
endforeach;
?>
</ul>
<div class="clear"></div>
</p>
</div><!-- End member-->
<?php endforeach; ?>
class Categories_model extends Base_module_model {
public $record_class = 'Category';
public $parsed_fields = array('content', 'content_formatted');
function __construct()
{
parent::__construct('categories');
}
}
class Category_model extends Base_module_record {
function get_members($subCategory)
{
$this->_CI->load->model('categories_to_members_model');
$where = array('category_id' => $this->id, 'sub_cat_id' => $subCategory, 'members.published' => 'yes');***
$members = $this->_CI->categories_to_members_model->find_all($where);
return $members;
}
}
class Categories_to_members_model extends MY_Model {
public $record_class = 'Category_to_member';
//public $foreign_keys = array('category_id' => 'categories_model', 'member_id' => 'members_model');
public $foreign_keys = array('category_id' => 'categories_model', 'sub_cat_id' => 'sub_categories_model', 'member_id' => 'members_model');
public $parsed_fields = array('content', 'content_formatted');
function __construct()
{
parent::__construct('categories_to_members');
}
function _common_query()
{
$this->db->select('categories_to_members.*, members.title, members.id, members.content, members.address, members.phone, members.site, members.logo, categories.name AS category_name, categories.published');
$this->db->join('members', 'categories_to_members.member_id = members.id', 'left');
$this->db->join('categories', 'categories_to_members.category_id = categories.id', 'left');
$this->db->join('sub_categories', 'categories_to_members.sub_cat_id = sub_categories.id', 'left');***
}
}
class Category_to_member_model extends Data_record {
public $category_name = '';
public $title = '';
function get_excerpt_formatted($char_limit = NULL, $readmore = '')
{
$this->_CI->load->helper('typography');
$this->_CI->load->helper('text');
$excerpt = $this->content;
if (!empty($char_limit))
{
// must strip tags to get accruate character count
$excerpt = strip_tags($excerpt);
$excerpt = character_limiter($excerpt, $char_limit);
}
$excerpt = auto_typography($excerpt);
$excerpt = $this->_parse($excerpt);
if (!empty($readmore))
{
$excerpt .= ' '.anchor($this->get_url(), $readmore, 'class="readmore"');
}
return $excerpt;
}
}
Comments
// use get_members instead of just members for the method name $members = $category->get_members($subCategory);
You have to use the method name in this case because you are passing a parameter.