Frontend Editing
29 October 2006, lunch time
I’ve made a plugin to allow for front end editing. From the help:
This plugin will add a link to your posts that will take you directly the edit screen in your textpattern install. The link is hidden by a cookie that you can turn on or off. You will need to be logged in to textpattern to be able to actually edit the post, this plugin provides a shortcut from a post directly to the edit screen.
First upload the files
rsx_frontend_on.php
andrsx_frontend_off.php
to your website, and place them in a location you can reach. Thetextpattern
directory is a good spot. You will need to run the rsx_frontend_on.php file to toggle the visibilty of the frontend edit link on. You can run the file rsx_frontend_off.php to turn the visibility off.Simply place the tag
<txp:rsx_frontend_edit_link> link text </txp:rsx_frontend_edit_link>
anywhere on a form you use to display a post. This will create a link to the edit screen for that post.
If you want to use the plugin, grab this file: rsx_frontend_edit.txt. You will also need two php files to set and unset a cookie: rsx_frontend_on.php.txt, and rsx_frontend_off.php.txt. These last two files you will need to rename back to proper php files.
You can read more about this subject at brain-dump, though from a Moveable Type perspective.
Update: Small gug fix, $thing
has a default value of nothing incase it is not set.
Update April 5th 2005: The text between the link tags gets processed by Textpattern. This means you can use Textpattern tags like <txp:title />
as the value of your frontend edit link.
Update August 30th 2005: The plugin has been fixed so it works with Textpattern 4.0. The change is small, the variable formally known as $pfr
is now known as $hu
. If there are any problems let me know. This version will not work with older versions of Textpattern.
Update December 1st 2005: The plugin now uses the constant hu
, which I had thought was a variable earlier. There is a new tag, <txp:rsx_frontend_new_article_link>
which generates a link to an empty new entry page.
Update October 29th 2006: The plugin now uses <txp:php>
tags instead of raw php open and close tags. The raw tags have been deprecated.
All this work because I noticed that in my post about City of God I forgot a period at the end of the link to the official site. Now, to fix that involved:
# Clicking the bookmark to my textpattern install.
# Scrolling down the list of articles to find this article.
# Editing the article.
This plugin allows me to skip the first two steps.
Oh, I know you all wish you were as efficient as me. One day my friends, one day.
by ramanan on June 10 2004, 7:20 am #
why are you up at 4:20 in the morning doing all this? :s i worry about you.
by sh!ma on June 10 2004, 1:43 pm #
Sweet plug-in!
One correction in your posting though: you can’t place link text in between the tags in your forms. The code is hard set to displaty Edit automagically.
But regardless, a very sweet plug-in.
by Jeff Clark on June 12 2004, 3:08 pm #
This is why you shouldn’t program late at night. I’ll fix that shortly.
by ramanan on June 12 2004, 3:17 pm #
I got an PHP error message because of the ’$thing’ in the function-declaration:
function rsx_frontend_edit_link($atts,$thing)
After deleting the $thing, all works pretty well…
And I call it with:
txp:rsx_frontend_edit_link thing=”Edit” prefix=”Prefix” /
Looks simpler to me – no 2 tags needed.
by Ingo on October 2 2004, 7:06 pm #
I need to add a default value for the second parameter. I think this will fix the problem.
by ramanan on October 4 2004, 12:53 am #
Saw a link from PhotoDude that brought me here.
A simple and sweet plugin that scratches an itch I had. I particularly love that you provided a prefix and suffix parameter for adding extra bits of text outside the link text. Makes my “Edit this post” link appear beautifully after my Permalink spaced off just like between the date and Permalink.
by Marko on January 5 2005, 4:54 pm #
Glad you like it. This plug-in was much more thought out then some of my others. The prefix and suffix are there precisely to do what you are doing. On my page the link appears infront of the categories and is followed by a |.
by ramanan on January 5 2005, 6:50 pm #
Nice plugin Ramanan! quick tip: make sure there isn’t a space at the end of the second tag before the >, or textpattern will choke a little and it won’t work right.
by Kjell on January 5 2005, 8:36 pm #
Just wondered if it could be possible to replace the permlink tags with the frontend_edit_link tags in the main page? But it does not work, unfortunately. Why?
by peter on March 29 2005, 4:53 pm #
You should be able to change the textpattern form template so it no longer uses permalinks. That said, I can’t see why you would want to do this. Why would you not want permalinks to your posts?
by ramanan on March 29 2005, 7:13 pm #
Please look at my site (linked with my name). I am using textpattern as a tool for editing a multiauthor book. It is convenient to have an editing link to every chapter. Right now, I have the permlink and the frontend edit link next to each other, because for some reason I cannot use txp:title in combination with the frontend_edit_link tags.
by peter on March 30 2005, 5:20 am #
Oh, it is a mistake in the way I coded things. I will fix this tonight. If you look at the plugin source code, I place the value
$thing
between the generated link. This should be something likeparse($thing)
, so that textpattern processes the value.by ramanan on March 30 2005, 10:41 am #
Hi Ramanan, this is a thing I’ve been looking for – it takes Textpattern a step closer to a WikiWiki :-)
Just a small note to add: the frontend edit link is meaningless in an txp:if_article_list context. Maybe you could add such a check in the plugin?
by Premek on May 26 2005, 7:41 am #
Glad you like the plugin. I need to upgrade it so it will work with RC3 sooner.
I don’t want to add that check since people who list out their articles on the front page like myself may want direct access to the edit button without going to the individual archive page of a post.
by ramanan on May 26 2005, 10:47 am #
Yes, that’s obviously correct (want it that way myself :-) and fine, as long as the rsx_frontend tag is within the appropriate article form(s).
However, the tag can also be used in a page template, and if that page is used to format an article list, the edit button leads to nowhere since there is no article ID to be given. (This is what originally happened to me, which prompted my comment.)
But, I must admit, it may not be worth the effort since correct usage is the most effective check ;-)
by Premek on May 26 2005, 1:18 pm #
Hi I’m looking for someone who can help me with a plugin for Textpattern for a project in college. It would be a plugin that allows users to edit their comments. Thank you.
by rodrigo on July 27 2011, 3:21 pm #
I would post to the TextPattern forum. There may already be plugin’s that do that, though i’m not sure if plugin authors have access to user comments. (It’s been a while since I have looked at the TextPattern code seriously, or written any plugins.)
by ramanan on July 28 2011, 9:51 am #