x
 
Create New Page
 View Previous Changes    ( Last updated by Brandon Jones )

Edit Link With Entries

Question:

How can I add an Edit This link to existing entries on my site?

ExpressionEngine 2.0

{if author_id == logged_in_member_id OR logged_in_member_group == "1"}&bull; <a href="{cp_url}?S=0&D=cp&C=content_publish&M=entry_form&channel;_id={channel_id}&entry;_id={entry_id}">Edit This</a>{/if} 

You can place this in a Snippet called edit_this then place

{edit_this} 

Inside your {exp:channel:entries} tag where you want to include an edit link.

ExpressionEngine 1.x

If you’d like to show edit links only to the author of the entry, it is simple with 1.5+ and the Alternate Syntax.

Regarding the “admin.php” file below see this article. 

Importantly, note that the semicolons below (e.g. “weblog;_id   &  entry;_id” should be REMOVED when pasting this code into your page. 

To allow members to Edit through the Control Panel you may need to adjust the Member Group settings in the following:  CP Home ›  Admin ›  Members and Groups ›  Member Groups   ›  Edit Member Group.  Allow the group access to the Control Panel and allow them access to the Edit Page.

To restrict the member’s power to make changes you may choose to remove tabs in the Edit Page through the following:
CP Home ›  Admin ›  Weblog Administration ›  Weblog Management ›  Edit Weblog Preferences.  Choose “Publish Page Customization” at the bottom of the list of options.  Note that this will change the CP for all people who use it, not only that group.

{if logged_in_member_id == "{member_id}"}
        
<a href="/admin.php?C=edit&M=edit_entry&weblog;_id={weblog_id}&entry;_id={entry_id}">Edit</a>
    
{/if} 

If you prefer to show the edit link to the author or anyone that is a superadmin, then you can use advanced conditionals:

{if logged_in_member_id == "{member_id}" OR logged_in_group_id == "1"}
        
<a href="/admin.php?C=edit&M=edit_entry&weblog;_id={weblog_id}&entry;_id={entry_id}">Edit</a>
    
{/if} 

You may also create edit links for gallery entries:

{if logged_in_member_id == "{member_id}" OR logged_in_group_id == "1"}
        
<a href="/admin/index.php?S=0&C=modules&M=gallery&P=entry_form&gallery;_id={gallery_id}&entry;_id={entry_id}">Edit</a>
    
{/if} 

This code requires that you did Step 1. from the “Plain Edit This Link” section.  You can modify the code to use the Alternate Answer if you prefer.

Plain Edit This Link:

You can do this fairly easily. You’ll need to do the following:

1. Copy the admin.php file from system/utilities to the root of your site. If you are using any subdomains, copy admin.php to those directories as well. The reason to use the file admin.php is for consistancy between subdirectory domains (add-on domains) and domains where you have no subdomains.

2. Turn OFF sessions in your EE control panel. Otherwise, you may be prompted for your username and password if your session has expired.

3. Put in the following code snippet below the permalink information:

NOTE: text is wrapped here for display purposes, when using, put the href stuff on one line, and remove the ; before _id.

{if member_group=='1'
<a href="/admin.php?C=edit&M=edit_entry 
&weblog;_id={weblog_id}&entry;_id={entry_id}"
>Edit This</a
{/if} 

Alternate Answer:

This method is very similar to the above, however there is no need to copy/move your admin.php file. Use this method if you have no subdomains to work with.

1. Turn off sessions in your EE control panel. Sessions must be COOKIES only, otherwise you will have to re-login.

2. Place the following code where you would like your edit link to show. Next to, or below the entry title would be alright, however it is up to you.

NOTE: As above, text is wrapped display purposes (editorial line breaks designated with »). When pasting the code into your template, make sure it is all one line, and remove the ; before _id.

{if member_group == "1"
<a href="/system/index.php?C=edit&M=edit_entry&weblog;_id= » 
{weblog_id}&entry;_id={entry_id}" 
title="Edit Entry">Edit This</a
{/if} 

Also, make sure to replace ‘system’ with the given system name upon installation.

Category:Tips Category:Templates

Category:EE1

Categories: