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.

Reviews

This plugin doesn't have any reviews.

Active Installs
13
Version
5.0.0
License
Craft
Compatibility
Craft 4, Craft 5
Last release
March 28, 2024
Activity (30 days)
0
Closed Issues
0
Open Issues
0
Merged PRs
0
Open PRs