Problem/Motivation
Hi, I have a website with this menu:
{
"jsonapi": {
"version": "1.0",
"meta": {
"links": {
"self": {
"href": "http://jsonapi.org/format/1.0/"
}
}
}
},
"data": [
{
"type": "menu_link_content--menu_link_content",
"id": "standard.front_page",
"attributes": {
"description": "",
"enabled": true,
"expanded": false,
"menu_name": "main",
"meta": [],
"options": [],
"parent": "",
"provider": "standard",
"route": {
"name": "<front>",
"parameters": []
},
"title": "Home",
"url": "/export/web/it",
"weight": "0"
}
},
{
"type": "menu_link_content--menu_link_content",
"id": "menu_link_content:d7782fb2-b42e-4783-afb0-8aaad9d8a090",
"attributes": {
"description": null,
"enabled": true,
"expanded": false,
"menu_name": "main",
"meta": {
"entity_id": "1"
},
"options": [],
"parent": "",
"provider": "menu_link_content",
"route": {
"name": "entity.node.canonical",
"parameters": {
"node": "3"
}
},
"title": "articolo 1 it",
"url": "/export/web/it/articolo-1-it",
"weight": "0"
}
},
{
"type": "menu_link_content--menu_link_content",
"id": "menu_link_content:a6892f81-658a-48cf-8cf6-e2dedb45d8e7",
"attributes": {
"description": null,
"enabled": true,
"expanded": false,
"menu_name": "main",
"meta": {
"entity_id": "5"
},
"options": {
"attributes": {
"class": [
"classe-sottolink"
],
"id": "mio-id",
"target": "_blank"
}
},
"parent": "menu_link_content:d7782fb2-b42e-4783-afb0-8aaad9d8a090",
"provider": "menu_link_content",
"route": {
"name": "entity.node.canonical",
"parameters": {
"node": "10"
}
},
"title": "sotto articolo 1a it",
"url": "/export/web/it/sotto-articolo-1a-it",
"weight": "0"
}
},
{
"type": "menu_link_content--menu_link_content",
"id": "menu_link_content:60bc9c14-0623-471e-89ce-a394a3aec781",
"attributes": {
"description": null,
"enabled": true,
"expanded": false,
"menu_name": "main",
"meta": {
"entity_id": "7"
},
"options": [],
"parent": "menu_link_content:a6892f81-658a-48cf-8cf6-e2dedb45d8e7",
"provider": "menu_link_content",
"route": {
"name": "entity.node.canonical",
"parameters": {
"node": "11"
}
},
"title": "sotto sotto art it",
"url": "/export/web/it/sotto-sotto-art-it",
"weight": "0"
}
},
{
"type": "menu_link_content--menu_link_content",
"id": "menu_link_content:fe6b16af-13a6-4fb8-a361-74d2490dd157",
"attributes": {
"description": null,
"enabled": true,
"expanded": false,
"menu_name": "main",
"meta": {
"entity_id": "2"
},
"options": [],
"parent": "",
"provider": "menu_link_content",
"route": {
"name": "entity.node.canonical",
"parameters": {
"node": "4"
}
},
"title": "articolo 2 solo it",
"url": "/export/web/it/articolo-2-solo-it",
"weight": "0"
}
},
{
"type": "menu_link_content--menu_link_content",
"id": "menu_link_content:b18e8481-a7b1-459c-b296-5a528fff390c",
"attributes": {
"description": null,
"enabled": true,
"expanded": false,
"menu_name": "main",
"meta": {
"entity_id": "3"
},
"options": [],
"parent": "",
"provider": "menu_link_content",
"route": {
"name": "entity.node.canonical",
"parameters": {
"node": "5"
}
},
"title": "articolo 3 solo en",
"url": "/export/web/it/node/5",
"weight": "0"
}
},
{
"type": "menu_link_content--menu_link_content",
"id": "menu_link_content:e439be27-b0ef-4718-8d2c-2f7ea78abd7d",
"attributes": {
"description": null,
"enabled": true,
"expanded": false,
"menu_name": "main",
"meta": {
"entity_id": "4"
},
"options": {
"query": []
},
"parent": "",
"provider": "menu_link_content",
"route": {
"name": "view.elenco_it.page_1",
"parameters": []
},
"title": "elenco it",
"url": "/export/web/it/elenco-it",
"weight": "0"
}
},
{
"type": "menu_link_content--menu_link_content",
"id": "menu_link_content:03c078b1-4b69-4568-bb1d-e968d6ea2048",
"attributes": {
"description": null,
"enabled": true,
"expanded": false,
"menu_name": "main",
"meta": {
"entity_id": "6"
},
"options": {
"external": true
},
"parent": "",
"provider": "menu_link_content",
"route": {
"name": "",
"parameters": []
},
"title": "link esterno it",
"url": "https://www.usi.ch/it",
"weight": "0"
}
}
],
"links": {
"self": {
"href": "http://localhost:8888/export/web/it/jsonapi/menu_items/main"
}
}
}where there are:
- 6 first-level menu items
- 1 second-level menu item
- 1 third-level menu item
I am trying to add a simple filter from the README.md file:
http://export:export@localhost:8888/export/web/it/jsonapi/menu_items/mai...
but in the output there are always 8 menu items.
What am I getting wrong?
Thank you very much.
Steps to reproduce
Create a menu with different levels.
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork jsonapi_menu_items-3211656
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
decipheredHi @steva1982,
I did some tests, and I have confirmed there's an issue with the cacheability of filters. You will see the correct results by clearing the cache.
This is not at all a solution, but evidence that you should be able to get the correct data.
Comment #4
decipheredI've opened an MR with a fix for the issue, you can find the patch at: https://git.drupalcode.org/project/jsonapi_menu_items/-/merge_requests/3...
Comment #5
larowlanCode looks good 👍
Comment #7
decipheredFixed in 1.2.1
Comment #8
steva1982 commentedHi @Deciphered,
the code works!
Thank you very much.
Comment #9
decipheredYou’re very welcome. Thank you for reporting the issue.