Is there an easy and clean way to let users enter a node ID and be forwarded to the entry with the proper URL? (preferably not just /node/[id])

Background: I am creating a Backdrop site which accompanies a printed book listing all the sources. I want to print the NIDs in the book to give users easy access to the website records.

Most helpful answers

Would you kindly consider creating links in the manner of a standard reference, such as "[1] - Name of source," accompanied by the URL? In most cases, I prefer to ban the brute force of nodes ID.

You could probably do this with a View where the exposed filter is the node id and no results are shown if nothing entered or the number entered doesn't match a published node. The record could be re-written using the Rewrite results section to give a link (perhaps styled as button) with something like "Go to page" on in.

Here's an example:

{
    "_config_name": "views.view.nid_navigate",
    "name": "nid_navigate",
    "description": "",
    "tag": "",
    "disabled": false,
    "base_table": "node",
    "human_name": "Nid Navigate",
    "core": "1.34.2",
    "display": {
        "default": {
            "display_title": "Default",
            "display_plugin": "default",
            "display_options": {
                "query": {
                    "type": "views_query",
                    "options": []
                },
                "access": {
                    "type": "perm",
                    "perm": "access content"
                },
                "cache": {
                    "type": "none"
                },
                "exposed_form": {
                    "type": "basic",
                    "options": {
                        "submit_button": "Apply",
                        "reset_button": 0,
                        "reset_button_label": "Reset",
                        "exposed_sorts_label": "Sort by",
                        "expose_sort_order": 1,
                        "sort_asc_label": "Asc",
                        "sort_desc_label": "Desc",
                        "autosubmit": 1,
                        "autosubmit_hide": 1
                    }
                },
                "pager": {
                    "type": "some",
                    "options": {
                        "items_per_page": "1"
                    }
                },
                "style_plugin": "default",
                "row_plugin": "fields",
                "fields": {
                    "path": {
                        "id": "path",
                        "table": "node",
                        "field": "path",
                        "relationship": "none",
                        "group_type": "group",
                        "ui_name": "",
                        "label": "",
                        "exclude": 1,
                        "alter": {
                            "alter_text": 0,
                            "text": "",
                            "make_link": 0,
                            "path": "",
                            "absolute": 0,
                            "external": 0,
                            "replace_spaces": 0,
                            "path_case": "none",
                            "trim_whitespace": 0,
                            "alt": "",
                            "rel": "",
                            "link_class": "",
                            "prefix": "",
                            "suffix": "",
                            "target": "",
                            "nl2br": 0,
                            "max_length": "",
                            "word_boundary": 1,
                            "ellipsis": 1,
                            "more_link": 0,
                            "more_link_text": "",
                            "more_link_path": "",
                            "strip_tags": 0,
                            "trim": 0,
                            "preserve_tags": "",
                            "html": 0
                        },
                        "element_type": "",
                        "element_class": "",
                        "element_label_type": "",
                        "element_label_class": "",
                        "element_label_colon": false,
                        "element_wrapper_type": "",
                        "element_wrapper_class": "",
                        "element_default_classes": 1,
                        "empty": "",
                        "hide_empty": 0,
                        "empty_zero": 0,
                        "hide_alter_empty": 1,
                        "absolute": 0
                    },
                    "title": {
                        "id": "title",
                        "table": "node",
                        "field": "title",
                        "relationship": "none",
                        "group_type": "group",
                        "ui_name": "",
                        "label": "",
                        "exclude": 0,
                        "alter": {
                            "alter_text": 1,
                            "text": "<a href=\"[path]\">Go to page</a>",
                            "make_link": 0,
                            "path": "",
                            "absolute": 0,
                            "external": 0,
                            "replace_spaces": 0,
                            "path_case": "none",
                            "trim_whitespace": 0,
                            "alt": "",
                            "rel": "",
                            "link_class": "",
                            "prefix": "",
                            "suffix": "",
                            "target": "",
                            "nl2br": 0,
                            "max_length": "",
                            "word_boundary": 0,
                            "ellipsis": 0,
                            "more_link": 0,
                            "more_link_text": "",
                            "more_link_path": "",
                            "strip_tags": 0,
                            "trim": 0,
                            "preserve_tags": "",
                            "html": 0
                        },
                        "element_type": "",
                        "element_class": "",
                        "element_label_type": "",
                        "element_label_class": "",
                        "element_label_colon": false,
                        "element_wrapper_type": "",
                        "element_wrapper_class": "",
                        "element_default_classes": 1,
                        "empty": "",
                        "hide_empty": 0,
                        "empty_zero": 0,
                        "hide_alter_empty": 1,
                        "link_to_node": 0
                    }
                },
                "filters": {
                    "status": {
                        "value": 1,
                        "table": "node",
                        "field": "status",
                        "id": "status",
                        "expose": {
                            "operator": false
                        },
                        "group": 1
                    },
                    "nid": {
                        "id": "nid",
                        "table": "node",
                        "field": "nid",
                        "relationship": "none",
                        "group_type": "group",
                        "ui_name": "",
                        "operator": "=",
                        "value": {
                            "min": "",
                            "max": "",
                            "value": ""
                        },
                        "group": "1",
                        "exposed": true,
                        "expose": {
                            "operator_id": "nid_op",
                            "label": "",
                            "description": "",
                            "use_operator": 0,
                            "operator": "nid_op",
                            "identifier": "nid",
                            "required": 1,
                            "remember": 0,
                            "multiple": false,
                            "remember_roles": {
                                "authenticated": "authenticated",
                                "anonymous": 0,
                                "editor": 0,
                                "administrator": 0
                            }
                        },
                        "is_grouped": false,
                        "group_info": {
                            "label": "",
                            "description": "",
                            "identifier": "",
                            "optional": true,
                            "widget": "select",
                            "multiple": false,
                            "remember": 0,
                            "default_group": "All",
                            "default_group_multiple": [],
                            "group_items": []
                        }
                    }
                },
                "sorts": {
                    "created": {
                        "id": "created",
                        "table": "node",
                        "field": "created",
                        "order": "DESC"
                    }
                },
                "title": "Direct Navigate",
                "empty": {
                    "area": {
                        "id": "area",
                        "table": "views",
                        "field": "area",
                        "relationship": "none",
                        "group_type": "group",
                        "ui_name": "",
                        "label": "",
                        "empty": true,
                        "content": "<p>Enter a valid ID to go to a page</p>",
                        "format": "filtered_html",
                        "tokenize": 0
                    }
                },
                "use_ajax": true,
                "enable_ajax_history": false
            }
        },
        "block_nid_navigate": {
            "display_title": "Block",
            "display_plugin": "block",
            "display_options": {
                "query": {
                    "type": "views_query",
                    "options": []
                },
                "exclude_ajax_args": ""
            }
        }
    }
}

Comments

You could probably do this with a View where the exposed filter is the node id and no results are shown if nothing entered or the number entered doesn't match a published node. The record could be re-written using the Rewrite results section to give a link (perhaps styled as button) with something like "Go to page" on in.

Here's an example:

{
    "_config_name": "views.view.nid_navigate",
    "name": "nid_navigate",
    "description": "",
    "tag": "",
    "disabled": false,
    "base_table": "node",
    "human_name": "Nid Navigate",
    "core": "1.34.2",
    "display": {
        "default": {
            "display_title": "Default",
            "display_plugin": "default",
            "display_options": {
                "query": {
                    "type": "views_query",
                    "options": []
                },
                "access": {
                    "type": "perm",
                    "perm": "access content"
                },
                "cache": {
                    "type": "none"
                },
                "exposed_form": {
                    "type": "basic",
                    "options": {
                        "submit_button": "Apply",
                        "reset_button": 0,
                        "reset_button_label": "Reset",
                        "exposed_sorts_label": "Sort by",
                        "expose_sort_order": 1,
                        "sort_asc_label": "Asc",
                        "sort_desc_label": "Desc",
                        "autosubmit": 1,
                        "autosubmit_hide": 1
                    }
                },
                "pager": {
                    "type": "some",
                    "options": {
                        "items_per_page": "1"
                    }
                },
                "style_plugin": "default",
                "row_plugin": "fields",
                "fields": {
                    "path": {
                        "id": "path",
                        "table": "node",
                        "field": "path",
                        "relationship": "none",
                        "group_type": "group",
                        "ui_name": "",
                        "label": "",
                        "exclude": 1,
                        "alter": {
                            "alter_text": 0,
                            "text": "",
                            "make_link": 0,
                            "path": "",
                            "absolute": 0,
                            "external": 0,
                            "replace_spaces": 0,
                            "path_case": "none",
                            "trim_whitespace": 0,
                            "alt": "",
                            "rel": "",
                            "link_class": "",
                            "prefix": "",
                            "suffix": "",
                            "target": "",
                            "nl2br": 0,
                            "max_length": "",
                            "word_boundary": 1,
                            "ellipsis": 1,
                            "more_link": 0,
                            "more_link_text": "",
                            "more_link_path": "",
                            "strip_tags": 0,
                            "trim": 0,
                            "preserve_tags": "",
                            "html": 0
                        },
                        "element_type": "",
                        "element_class": "",
                        "element_label_type": "",
                        "element_label_class": "",
                        "element_label_colon": false,
                        "element_wrapper_type": "",
                        "element_wrapper_class": "",
                        "element_default_classes": 1,
                        "empty": "",
                        "hide_empty": 0,
                        "empty_zero": 0,
                        "hide_alter_empty": 1,
                        "absolute": 0
                    },
                    "title": {
                        "id": "title",
                        "table": "node",
                        "field": "title",
                        "relationship": "none",
                        "group_type": "group",
                        "ui_name": "",
                        "label": "",
                        "exclude": 0,
                        "alter": {
                            "alter_text": 1,
                            "text": "<a href=\"[path]\">Go to page</a>",
                            "make_link": 0,
                            "path": "",
                            "absolute": 0,
                            "external": 0,
                            "replace_spaces": 0,
                            "path_case": "none",
                            "trim_whitespace": 0,
                            "alt": "",
                            "rel": "",
                            "link_class": "",
                            "prefix": "",
                            "suffix": "",
                            "target": "",
                            "nl2br": 0,
                            "max_length": "",
                            "word_boundary": 0,
                            "ellipsis": 0,
                            "more_link": 0,
                            "more_link_text": "",
                            "more_link_path": "",
                            "strip_tags": 0,
                            "trim": 0,
                            "preserve_tags": "",
                            "html": 0
                        },
                        "element_type": "",
                        "element_class": "",
                        "element_label_type": "",
                        "element_label_class": "",
                        "element_label_colon": false,
                        "element_wrapper_type": "",
                        "element_wrapper_class": "",
                        "element_default_classes": 1,
                        "empty": "",
                        "hide_empty": 0,
                        "empty_zero": 0,
                        "hide_alter_empty": 1,
                        "link_to_node": 0
                    }
                },
                "filters": {
                    "status": {
                        "value": 1,
                        "table": "node",
                        "field": "status",
                        "id": "status",
                        "expose": {
                            "operator": false
                        },
                        "group": 1
                    },
                    "nid": {
                        "id": "nid",
                        "table": "node",
                        "field": "nid",
                        "relationship": "none",
                        "group_type": "group",
                        "ui_name": "",
                        "operator": "=",
                        "value": {
                            "min": "",
                            "max": "",
                            "value": ""
                        },
                        "group": "1",
                        "exposed": true,
                        "expose": {
                            "operator_id": "nid_op",
                            "label": "",
                            "description": "",
                            "use_operator": 0,
                            "operator": "nid_op",
                            "identifier": "nid",
                            "required": 1,
                            "remember": 0,
                            "multiple": false,
                            "remember_roles": {
                                "authenticated": "authenticated",
                                "anonymous": 0,
                                "editor": 0,
                                "administrator": 0
                            }
                        },
                        "is_grouped": false,
                        "group_info": {
                            "label": "",
                            "description": "",
                            "identifier": "",
                            "optional": true,
                            "widget": "select",
                            "multiple": false,
                            "remember": 0,
                            "default_group": "All",
                            "default_group_multiple": [],
                            "group_items": []
                        }
                    }
                },
                "sorts": {
                    "created": {
                        "id": "created",
                        "table": "node",
                        "field": "created",
                        "order": "DESC"
                    }
                },
                "title": "Direct Navigate",
                "empty": {
                    "area": {
                        "id": "area",
                        "table": "views",
                        "field": "area",
                        "relationship": "none",
                        "group_type": "group",
                        "ui_name": "",
                        "label": "",
                        "empty": true,
                        "content": "<p>Enter a valid ID to go to a page</p>",
                        "format": "filtered_html",
                        "tokenize": 0
                    }
                },
                "use_ajax": true,
                "enable_ajax_history": false
            }
        },
        "block_nid_navigate": {
            "display_title": "Block",
            "display_plugin": "block",
            "display_options": {
                "query": {
                    "type": "views_query",
                    "options": []
                },
                "exclude_ajax_args": ""
            }
        }
    }
}

Just to say I discovered an issue with doing this, which I have documented here.

https://github.com/backdrop/backdrop-issues/issues/7168

To make this work, before this issue is resolved, you need to not make it "Required" when adding to the layout or making any changes to the layout that need saving.

OR, you can add a value to the required filter (e.g. 0) that the user would have to overwrite.

findlabnet's picture

Would you kindly consider creating links in the manner of a standard reference, such as "[1] - Name of source," accompanied by the URL? In most cases, I prefer to ban the brute force of nodes ID.

You could probably do this with a View where the exposed filter is the node id

Ah, interesting idea. Thanks!

Would you kindly consider creating links in the manner of a standard reference

To be clear, full references are given as well. I am just thinking about an additional convenient way to access the entries without typing long URLs or long titles. But come to think of it, I could probably just add an additional “short reference field” and readers can just use something “Miller 1843” with  the standard search form. 🤔 That might be a good compromise.