Context Navigation

Top-Level Navigation

Getting the top 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": [],
            "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 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., so a request would look like:

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