1

I have a very simple view of content filtered by content type. Multiple content types are selected. For example, I am listing the latest contents of type Event, Forum topic, and Article. I am using Views Ticker display for this view.

Now I got a new request. Since there are so many articles being published (they are synced from an external publishers), the view should only show the amount of the articles, but it should still list other content types individually. An example output should look somewhat like that:

  • Forum topic: Lorem ipsum
  • Forum topic: Dolor amet
  • New 26 articles
  • Event: Meeting
  • Forum topic: XYZ

How can I aggregate only for one content type in views? Can I use some view hooks to achieve that? Like hook_views_pre_render(), etc?

Since I am using Views Ticker as display plugin, I cannot simply add them to footer or header.

  • 1
    Could you just create a second view display for the article nodes - with its own, separate settings - and attach it to the bottom or top of the first view? – Boriana Ditcheva Dec 9 '13 at 21:25
  • The view is a views ticker, i.e. the list of results are scrolling vertically. Putting the articles on header or footer wouldn't help on this case. – Елин Й. Dec 10 '13 at 5:30
  • I'd try with post execute hook, but that's just what feels right, not enough to put as an answer. – Mołot Jan 21 '14 at 13:16
  • Thanks @Mołot I'll definitely give it a try and give you a feedback. – Елин Й. Jan 21 '14 at 14:46
  • @Mołot I tried with post execute hook, it was almost nearly what I am looking for, but I got another problem, that I show only last 10 items in that display and Views Ticker doesn't support pagers. So to be able to use post execute hook, I need first query all items, which would very bad for performance. But I'll give it a one more try this week, querying the nodes for the last week maybe, then I'll try to aggregate the articles with post execute hook, than reduce the item count to 10 via php instead of query. Thanks so far :) – Елин Й. Jan 28 '14 at 9:16
1
+50

I have a feeling there may be a solution using a separate view with aggregation and then using the Views Field View module to embed the aggregated view as a field.

Another option (which feels like a bit of a cop-out and cheating) would be to create a content type called "articles count".

Then each time you do a sync with the external publisher you update the "articles count" node title to be "New [count] articles", and set the body to be a list of links to each of the new articles. This is neat as you always have an index to your new articles.

Then simply include this as one of your content types in the original view. To be honest this is probably the easiest way.

  • Hi, I'll give you the bounty since there are no better suggestions till now. Creating another node type to hold the synced article count is a creative suggestion, but I don't think that I'll get this workaround into project, since we have already a lot of content types and I don't think that I could convince the other team members in the project to take this approach. I'll go with post execute hook as Mołot has suggested and try my best to get the ticker as much as possible to look like how it is required from the client. Thanks. – Елин Й. Jan 28 '14 at 9:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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