I have cck content type with a variety of fields - video, taxonomy of terms, images, etc - in drupal 7, core 7.8. Unfortunately, I'm unable to group the results of the page view by a cck field by simply filtering and changing format settings by Group Field - UNLESS, I update my Drupal Core (tested w/ 7.12 and works easily). I am, however, able to group via using content: post date.

I've read through several answers on stack-xchg, ie. Grouping a View by Custom Field - but didn't really find an alternative way to group fields in the event I am not permitted to update core or modules.

Is there a way I can group fields by cck field via code? Thanks,

1 Answer 1


You can do almost anything you want within a views template. If you look at the Theme Information in the View UI, you can see what you can modify, or just cd into modules/views/theme and take a peek at them. But, given that the $view variable is available to almost if not all of the templates (whether or not the comments say it is), and $view->result is an array of row values of the view, you can certainly foreach() through it and do whatever you want. Otherwise, you have the whole gamut of preprocess() hooks, views_pre_render() of which is probably most of interest here.

  • Thats a fantastic suggestion that slipped from thought. I could traverse my dataset, picking out unique custom cck field that I want to group by, list content that matches in a views template! Will try and update.
    – Robbase
    Mar 5, 2012 at 19:21
  • Calling hook_views_pre_render in a custom module allowed me to collect all my views results, and work on it. Therefore your suggestion does satisfy an alternate solution, many thanks! Unfortunately, I opened a new request due to pagination limits - drupal.stackexchange.com/questions/24739/….
    – Robbase
    Mar 6, 2012 at 21:42
  • you may have to do all that paging yourself, which isn't that diffucult. if you put together a pretty detailed explanation of your data and grouping information, it might help out finding a specific answer
    – Jimajamma
    Mar 6, 2012 at 22:50
  • quick thought--would sorting by the content type you are grouping on have the effect of grouping the ones you want together in the group displayed per page?
    – Jimajamma
    Mar 6, 2012 at 23:56
  • Jimajamma, I'll provide the layout in the other question I posted relative to this - drupal.stackexchange.com/questions/24739/…
    – Robbase
    Mar 7, 2012 at 12:48

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.