The Entry Editor Links plugin helps generate links to the Craft CMS entry editor for a given entry. This functionality is easy to create in Twig templates, but if you have a statically cached page, like with FastCGI Cache, you could run into instances where the edit entry link is shown to a user who doesn't have permission to edit the entry.

This plugin solves that problem by providing a Twig function that can be used to determine if a page is being rendered on the front end of the site. If so, you can render a data-edit-link attribute on the element in your template displaying the entry ID. Then, using JavaScript, you can query the plugin's API endpoint, which will return the control panel edit URL if the user is logged in and has permission to edit the entry. Then you can add a link to the entry's edit page in the DOM.

Exposing only an entry ID helps prevent leaking information about your site's structure to users who don't have permission to edit entries.

Plugin functionality

The plugin does two things:

  1. It provides an endpoint that expects an entry ID and returns a JSON object with the entry's edit URL.
  2. It also provides a Twig function, isFrontEndPageView(), to determine if a page is being rendered on the site's front end. This is to prevent the edit links from being displayed when a user has the preview pane open while editing an entry in the control panel or if the entry is rendered on the site's front end using a preview token.
Installation Instructions

To install this plugin, copy the command above to your terminal.

Active Installs
9
Version
1.0.3
License
Craft
Compatibility
Craft 4
Last release
June 4, 2023
Activity (30 days)
0
Closed Issues
0
Open Issues
0
Merged PRs
0
Open PRs