Trouble sorting tagged articles

edited July 2014 in Modules
$category = uri_segment(2); if ($category) : $tag = fuel_model('tags', array('find' => 'one', 'where' => array('slug' => $category))); $articles = $tag->articles; $articles_model = $tag->get_articles(TRUE); if (!empty($articles_model)) : $featured_images = $articles_model->find_all(array('featured_image !=' => '')); else : $featured_images = ''; endif; else : redirect_404(); endif;
How can I add order post_date desc for all the tagged articles? I tried $articles_sorted = $articles_model->find_all(array(), 'post_date desc'); but then my $featured_images stop working. I wasn't sure if I could sort it with $articles_model first, if that makes sense, haha.

Comments

  • edited 2:55PM
    $articles_model is the articles model with the where_in active record already applied so any subsequent queries will include that where_in query too. So yes, you can do 'post_date desc' for the sorting. What does the query say if you do $articles_model->debug_query() right after the find_all?
Sign In or Register to comment.