0

I'm building an api that is going to change base on the title and the language that is been request. This request is base on the URL something like this www.example.com/abc/fr-fr

  • abc = title of the content

  • fr-fr = Language Code name

For some reason the context filter of the language is turning my search into empty. Here is what happen when I try to run www.example.com/abc/fr-fr

{
  "nodes" : []
}

And it should looks like this instead:

{
  "nodes" : [
    {
      "node" : {
        "Literal Api" : "{\n \"glossary\": {\n \"title\": \"example glossary\",\n\t\t\"GlossDiv\": {\n \"title\": \"S\",\n\t\t\t\"GlossList\": {\n \"GlossEntry\": {\n \"ID\": \"SGML\",\n\t\t\t\t\t\"SortAs\": \"SGML\",\n\t\t\t\t\t\"GlossTerm\": \"Standard Generalized Markup Language\",\n\t\t\t\t\t\"Acronym\": \"SGML\",\n\t\t\t\t\t\"Abbrev\": \"ISO 8879:1986\",\n\t\t\t\t\t\"GlossDef\": {\n \"para\": \"A meta-markup language, used to create markup languages such as DocBook.\",\n\t\t\t\t\t\t\"GlossSeeAlso\": [\"GML\", \"XML\"]\n },\n\t\t\t\t\t\"GlossSee\": \"markup\"\n }\n }\n }\n }\n}",
        "Title" : "abc",
        "Language" : "French"
      }
    }
  ]
}

Things that I have already try it out:

  1. I thought that the problem was having multiple contextual filters but that did not fix the problem because I try using it only the language contextual filter and I still have the same problem.

  2. Also, I try to use the word "French" instead of the language code, which is "fr-fr" and this did not fix the problem.

Here is my view configuration: View Configuration

Note I'm using node translation in 7, not entity/field translation. Each language has its own copy of a node.

My question is why I'm getting an empty node instead of the entire node information?

  • I believe you can only use 1 contextual filter using 2 or more will give you blanks. – No Sssweat Dec 3 '15 at 0:22
  • @NoSssweat any reference for this claim? As far as I remember, it's simply not true. – Mołot Dec 3 '15 at 0:24
  • @Molot no reference, speaking from experience. Every time I've tried using 2, the view breaks. – No Sssweat Dec 3 '15 at 0:25
  • 1
    @NoSssweat either your version has a bug, you are unlucky, or you are doing something wrong. In order of probability. – Mołot Dec 3 '15 at 0:27
  • 1
    Long time ago, multiple contextual filter was not supported it. However, the latest version of views I know support multiple contextual filter because I have done it on other places. See my first bullet points on things that I have try it out. I thought that the problem was having multiple contextual filters but that did not fix the problem because I try using it only the language contextual filter and I still have the same problem. – itsdarrylnorris Dec 3 '15 at 0:31
2

Multiple contextual filters are fine & dandy. The issue seems to be that the url prefix being used in a translated/localized content is a bit different from the actual machine code for the language. French is not 'fr-fr' but simply 'fr' in Drupal's views. French Canadian would be 'fr-ca'.

here is a list of defined languages I use on my site along with their codes. These should be what you're looking to filter on. No issues with multiple filters.

enter image description here

| improve this answer | |
  • I was using the wrong language code. This seem to solve my problem thank you. – itsdarrylnorris Dec 3 '15 at 0:32

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.