开发者

Drupal Views/Services: Want the 5 latest nodes for all terms in one query (Nested Views or Subviews)

开发者 https://www.devze.com 2023-02-16 08:18 出处:网络
I\'m using a Drupal 6 CMS as a JSON based REST service provider for a custom client. I\'m currently using 2 views for the content:

I'm using a Drupal 6 CMS as a JSON based REST service provider for a custom client. I'm currently using 2 views for the content:

  • A view to get all taxonomy terms
  • A view to get the 5 latest published nodes for each term

At the moment I'm using quite a lot of requests to get the following data:

  • List of Taxonomy Terms (1 Request)
  • The 5 latest nodes for every term (1 Request per term, typically about 10 requests)

I'd like to reduce my communication overhead by providing this 开发者_高级运维data in 1 Request. This means I should create a View that retrieves the following data:

- Term ID 1
  - Node 1
  - Node 2
  - Node 3
  - Node 4
  - Node 5
- Term ID 1
  - Node 6
  - Node 7
  - Node 8
  - Node 9
  - Node 10

etc

In order to create this, I would need some subview mechanism or subview mechanism, something as powerfull as the subquery mechanism in SQL.

Any ideas on how to realize this?

I could try the php coding route, but I'd like to avoid it in this project and keep the Drupal installation as vanilla as possible (aside from installing additional modules)


I'm not sure if this can be done via Views.

If this only serves as a JSON interface, you can code it by yourself as a regular query. Write a module that retrieves the data you want and return it in a way that you can process it. You could do this by creating a custom site (eg. www.mysite.com/my_json_result) so that your service can access it.


Someone is working on a module to do something like this allready, http://drupal.org/project/services_views, take a look.

0

精彩评论

暂无评论...
验证码 换一张
取 消