1

I am using Drupal 7. I want to create a module which shows All the latest posts in Group with sorting options for the posts(a dropdown for sorting posts in block with various options). I am using organic group module for group management.

I have created a block module which can fetch the content for the particular group, but I am not able to manage sorting drop down form.

Does any one have idea, how to display form in block output and then sort that form.

I am also using file attachment with posts in group. So my sorting parameters includes no of files in post, postdate(i can get using views), Most viewed, Most comment,

Note: I want to build custom module because first I tried with Views module, but I am not able to get various sorting parameters which i need for sorting

2
  • What are all various sorting parameters you are looking for ? Please complete your question !! Current form it's not a right fit for answers.
    – Anil Sagar
    Commented Oct 22, 2012 at 4:55
  • @AnilSagar I have added parameters, have a look at it Commented Oct 22, 2012 at 4:59

1 Answer 1

0

You can do it with views + some minimal coding in your module: Make the view as you need, use a custom block to put 4 link with 4 different query arg: mysite.com/node/1?no_files=1, mysite.com/node/1?post_date=1 etc. For the dropdown you can use ctools jump menu feature, it's a simple drupal_get_form with this parameters.

If the dropdown is ok, let's modify the view's result based on query_arg: See hook_views_query_alter.

To get how do you need to change the query, I'm used to create the same view with all different filter what I need, and put file_put_contents('/tmp/log', var_export($query)); into your _view_query_alter implementation. If all different query of views are in log, it's easy to figure out, what do you need to modify in $query.

To order your views by file attachment exists, just add a filter named Field: Your File Attachment to the view, and use the operator Is Not Empty (NOT NULL). (As I understand, in this one case, you want to filter the query, not to sort.)

Most comment sorting need the sort criteria: Content: Comment count, Most viewed is not so exact, it depends, what do you use to tracking content viewing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.