Excluding a Tag from a posts query
I'm still running the 9.3 version of fuel. Inside this class:
class Fuel_posts extends Fuel_advanced_module {
I have:
function recent($limit = 5, $where = array())
{
$posts = $this->posts($where, 'post_date desc', $limit);
return $posts;
}
How would I create a similar method that excluded a certain tag from the list of posts returned?
I have another method that grabs all the posts for a particular tag, but it seems excluding just one tag isn't quite as straightforward. Can someone point me in the right direction.
Comments
Are you looking for something like a where condition with the following:
$where['fuel_tags.slug !='] =$tag;
Unknown column 'fuel_tags.slug' in 'where clause'
So I'd need to join in the fuel_tags table right? I'm not seeing how to do this.
$this->CI->load->module_model(POSTS_FOLDER, 'posts_model'); $this->CI->posts_model->readonly = TRUE; $this->CI->posts_model->db()->join('fuel_relationships', 'fuel_posts.id = fuel_relationships.candidate_key', 'INNER'); $this->CI->posts_model->db()->join('fuel_tags', 'fuel_relationships.foreign_key = fuel_tags.id', 'INNER'); $where['fuel_tags.slug !='] = $tag; $posts = $this->CI->posts_model->find_all($where, 'post_date desc', $limit, NULL, NULL, NULL); return $posts;