We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Plugin: Edit Link

Development and Programming

notacouch's avatar
notacouch
92 posts
16 years ago
notacouch's avatar notacouch

In my last project I wanted a convenient way to insert edit links any way I wanted without having to worry about which group would have edit access later on.

For some time I used embedded templates but eventually I figured it was better to use a plugin. Since the project went live and it works fine there I feel it’s alright to share it now. You can use it to print out edit/publish links to either anyone who has access or to specific member groups. You must provide the entry_id and weblog_id if it’s an edit/publish link. The only other type of link this can create is to a Simple Commerce Module item, for this you only need to provide the entry_id.

You can use it in a variety of ways.

Usage (note though this is a tag pair there is nothing inside):

{exp:edit_link entry_id="{entry_id}" weblog_id="{weblog_id}"}{/exp:edit_link}

This would result in:

<a href="http://path/to/system/index.php?C=edit&M=edit_entry&weblog_id=#&entry_id=#" rel="external">Edit this page.</a>

You can change the text inside the link via the text parameter

{exp:edit_link text="Edit link" entry_id="{entry_id}" weblog_id="{weblog_id}"}{/exp:edit_link}

or via an {edit_link}Edit link{/edit_link} variable pair inside the tag pair.

<a href="http://path/to/system/index.php?C=edit&M=edit_entry&weblog_id=#&entry_id=#" rel="external">Edit link</a>

You can change the text before and after the link via the pre_link_text and post_link_text parameters, e.g. with values of “(” and “)” to enclose the link in parentheses. Or you can use the variable {edit_link}:

{exp:edit_link text="Edit link" entry_id="{entry_id}" weblog_id="{weblog_id}"}({edit_link}){/exp:edit_link}

Another output based parameter is “tag” in case you want to wrap a tag around the edit link. This tag will receive a class of edit_link e.g. tag=”p” will wrap e.g.

...

around the edit link.

Use parameter group_ids (pipe-delimited (“|”) list of group member IDs that you want to limit access to, Super Admin is always granted access) in conjunction with restrict_to_groups (default is false, i.e. a loose setting, anyone with edit/publish access to provided weblog will see the edit link).

To print a publish entry link

{exp:edit_link:publish text="Publish an entry" weblog_id="{weblog_id}"}{/exp:edit_link}

To print an edit SCM item link (not tested extensively, tests if the user has access to the modules tab)

{exp:edit_link:simple_commerce text="Simple Commerce" entry_id="{entry_id}"}{/exp:edit_link}

Lastly you don’t even need to use this to print out a link per se, e.g. if you only wanted certain snippets of code to appear to the members who have edit access to that particular weblog then you can use it as above without using the {edit_link} variable provided the required info is passed to the plugin and the logged in user has the proper credentials, too.

Parameters for {exp:edit_link}: - group_ids: (default: 1) Member must belong to a group of this id, also takes ‘|’-delimited ids for multiple groups. Plugin quits if member does not meet this criteria. - restrict_to_groups: (default: ‘false’) If you only want to show the link to specified member groups despite others having edit access, too. - entry_id: (Required unless publishing an entry) The entry_id for the entry. Plugin quits if one is not supplied. - weblog_id: The weblog_id for the entry (not needed when using {exp:edit_link:simple_commerce}). - pre_link_text: Text that precedes the anchor tag. - text: (default: ‘Edit this page.’) Text that goes within the anchor element. - post_link_text: Text that follows the anchor tag. - tag: (overrides open_tag and close_tag) HTML tag that wraps the anchor, has class of ‘edit’. - open_tag: Opening HTML tag that precedes anchor, has class of ‘edit’, does not have a closing tag unless specified. - close_tag: Closing HTML tag that follows anchor, does not have a opening tag unless specified. - C: (default: ‘edit’) C request value. - M: (default: ‘edit_entry’) M request value. - P: P request value. - debug: If set to ‘true’ instead of returning blank on error plugin should try to return informative error messages. Be cautious when using on live sites/pages as it will be revealed to all users.

Some possible caveats: -I’ve never used SAEFs, this is just for pointing to the EE control panel -I wasn’t sure how to determine the location of the control panel -I’ve never used MSM so admittedly I’m not yet conscious of multiple sites under one EE install let alone how to accommodate for them

Versioning is arbitrary. Released at 0.5.

       
Max Lazar's avatar
Max Lazar
337 posts
16 years ago
Max Lazar's avatar Max Lazar

Brandon Kelly Editor 1.0.2?

       
notacouch's avatar
notacouch
92 posts
16 years ago
notacouch's avatar notacouch

Yeah I’ve heard of it, haven’t tried it out though.

and the edit buttons will automagically appear.

That’s what turned me off. I wanted complete control over where and how it shows up not to mention the added bonus of not even necessarily putting a link in there.

       
Ingmar Greil's avatar
Ingmar Greil
29,243 posts
16 years ago
Ingmar Greil's avatar Ingmar Greil

Just for reference, here’s another link: http://ellislab.com/forums/viewthread/111698/

       
notacouch's avatar
notacouch
92 posts
16 years ago
notacouch's avatar notacouch
Just for reference, here’s another link: http://ellislab.com/forums/viewthread/111698/

Ah. Didn’t know about that. I don’t think it existed when I made/was working on this.

       
lincolnpixel's avatar
lincolnpixel
76 posts
15 years ago
lincolnpixel's avatar lincolnpixel

Hi,

is it possible to change the text inside the link with an icon?

thanks

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.