Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Choose language using views services in drupal 7

I use views services module with rest services. The views shows content using "current user's language" but when I get content always returns in the default language.

For example:

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

Returns

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

I need choose language in rest petition.

like image 550
manupi26 Avatar asked Feb 17 '26 00:02

manupi26


1 Answers

From 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

So you can create a exposed filter for language in your view and than just filter results by adding &lang=en to the url:

http://example.com/api1_rest/views/content_view?id_display=page&limit=10&offset=0&lang=en
like image 153
kalo Avatar answered Feb 19 '26 14:02

kalo