简体   繁体   中英

Display unique node using views in drupal

I am trying to display latest articles using views module. There are 12 article should be displayed per click of pagination excluding the duplicate entry. So, I tried as:

  • checked Advanced > Query settings > Distinct but no luck.

  • I have also tried as Views Distinct Settings > Filter/Aggregate this field > Filter Repeat , it works but number of articles are displayed less than 12.

Then, I tried to do it using the hook mymodule_views_query_alter but I do not understand how can I accomplish this task. I tried as:

if($view->current_display == "latest_article"){
    $query->add_groupby('node.title');
}

But no solution. How can I override the query and inject DISTINCT function to get unique record.

Did you tried using Use aggregation option from Advanced section ? Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM