我将 View 服务模块与休息服务一起使用。 View 使用“当前用户的语言”显示内容,但当我获取内容时,总是以默认语言返回。
例如:
http://example.com/api1_rest/views/content_view?id_display=page&limit=10&offset=0
返回
[
{
"vid":"300",
"uid":"4",
"title":"node title",
"log":"",
"status":"1",
"comment":"0",
"promote":"0",
"sticky":"0",
"nid":"2488",
"type":"news",
"language":"en",
"revision_timestamp":"1422900078",
"revision_uid":"1",
"body":{
"en":[
{
"value":"content body here",
"summary":"",
"format":"4"
}
]
},
}
]
我需要在休息申请中选择语言。
最佳答案
来自 Services Views module page :
You can create exposed filters and pass them to your resource. For example if we created exposed filter "tags" call will be: http://example.com//?tags=7
因此,您可以在 View 中为语言创建一个公开的过滤器,而不仅仅是通过将 &lang=en 添加到 url 来过滤结果:
http://example.com/api1_rest/views/content_view?id_display=page&limit=10&offset=0&lang=en
关于web-services - 在 drupal 7 中使用 View 服务选择语言,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29507850/