2015-04-08 45 views
3

我使用視圖服務模塊與休息服務。視圖使用「當前用戶的語言」顯示內容,但是當我獲得內容時總是以默認語言返回。在drupal 7中使用視圖服務選擇語言

例如:

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" 
      } 
     ] 
     }, 
} 
] 

我需要選擇在休息請願語言。

回答

3

Services Views module page

您可以創建過濾器暴露並將它們傳遞到你的資源。例如,如果我們創建暴露過濾器「標籤」稱呼將是: http://example.com/ /標籤= 7

所以,你可以在你的視圖中創建一個對語言暴露過濾器,並不僅僅是通過增加& LANG = EN篩選結果到網址:

http://example.com/api1_rest/views/content_view?id_display=page&limit=10&offset=0&lang=en