Context Navigation#

Top-Level Navigation#

Get the top-level navigation items:

http

GET /plone/folder/@contextnavigation HTTP/1.1
Accept: application/json
Authorization: Basic YWRtaW46c2VjcmV0

curl

curl -i -X GET http://nohost/plone/folder/@contextnavigation -H "Accept: application/json" --user admin:secret

httpie

http http://nohost/plone/folder/@contextnavigation Accept:application/json -a admin:secret

python-requests

requests.get('http://nohost/plone/folder/@contextnavigation', headers={'Accept': 'application/json'}, auth=('admin', 'secret'))

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

{
    "@id": "http://localhost:55001/plone/folder/@contextnavigation",
    "available": true,
    "has_custom_name": false,
    "items": [
        {
            "@id": "http://localhost:55001/plone/folder/subfolder1",
            "description": "",
            "href": "http://localhost:55001/plone/folder/subfolder1",
            "icon": "",
            "is_current": false,
            "is_folderish": true,
            "is_in_path": false,
            "items": [
                {
                    "@id": "http://localhost:55001/plone/folder/subfolder1/thirdlevelfolder",
                    "description": "",
                    "href": "http://localhost:55001/plone/folder/subfolder1/thirdlevelfolder",
                    "icon": "",
                    "is_current": false,
                    "is_folderish": true,
                    "is_in_path": false,
                    "items": [
                        {
                            "@id": "http://localhost:55001/plone/folder/subfolder1/thirdlevelfolder/fourthlevelfolder",
                            "description": "",
                            "href": "http://localhost:55001/plone/folder/subfolder1/thirdlevelfolder/fourthlevelfolder",
                            "icon": "",
                            "is_current": false,
                            "is_folderish": true,
                            "is_in_path": false,
                            "items": [],
                            "normalized_id": "fourthlevelfolder",
                            "review_state": "private",
                            "thumb": "",
                            "title": "Fourth Level Folder",
                            "type": "folder"
                        }
                    ],
                    "normalized_id": "thirdlevelfolder",
                    "review_state": "private",
                    "thumb": "",
                    "title": "Third Level Folder",
                    "type": "folder"
                }
            ],
            "normalized_id": "subfolder1",
            "review_state": "private",
            "thumb": "",
            "title": "SubFolder 1",
            "type": "folder"
        },
        {
            "@id": "http://localhost:55001/plone/folder/subfolder2",
            "description": "",
            "href": "http://localhost:55001/plone/folder/subfolder2",
            "icon": "",
            "is_current": false,
            "is_folderish": true,
            "is_in_path": false,
            "items": [],
            "normalized_id": "subfolder2",
            "review_state": "private",
            "thumb": "",
            "title": "SubFolder 2",
            "type": "folder"
        },
        {
            "@id": "http://localhost:55001/plone/folder/doc1",
            "description": "",
            "href": "http://localhost:55001/plone/folder/doc1",
            "icon": "",
            "is_current": false,
            "is_folderish": false,
            "is_in_path": false,
            "items": [],
            "normalized_id": "doc1",
            "review_state": "private",
            "thumb": "",
            "title": "A document",
            "type": "document"
        }
    ],
    "title": "Navigation",
    "url": "http://localhost:55001/plone/sitemap"
}

The @contextnavigation endpoint uses the same semantics as the classic Plone navigation portlet, largely through reusing the same code. Instead of storing the portlet configuration in a portlet assignment storage, you can pass these as parameters to the service or expand the component.

You can provide these parameters:

  • name - The title of the navigation tree.

  • root_path - Root node path, can be "frontend path", derived from router

  • includeTop - Bool. Include top nodeschema

  • currentFolderOnly - Bool. Only show the contents of the current folder.

  • topLevel - Int. Start level

  • bottomLevel - Int. Navigation tree depth

  • no_icons - Bool. Suppress Icons

  • thumb_scale - String. Override thumb scale

  • no_thumbs - Bool. Suppress thumbs

You should prefix these parameters with expand.contextnavigation. A request would look like the following:

http://localhost:55001/plone/?expand.contextnavigation.topLevel=1&expand.contextnavigation.name=Custom+name