Question:
How can I add an Edit This link to existing entries on my site?
Edit Link for Author
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:
{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}
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.
{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.
{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}
Category:Tips Category:Templates
