A painting of me

Frontend Editing

   29 October 2006, early morning

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 and rsx_frontend_off.php to your website, and place them in a location you can reach. The textpattern 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.



  1. 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.

  2. why are you up at 4:20 in the morning doing all this? :s i worry about you.

  3. 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.

  4. This is why you shouldn’t program late at night. I’ll fix that shortly.

  5. 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.

  6. I need to add a default value for the second parameter. I think this will fix the problem.

  7. 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.

  8. 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 |.

  9. 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.

  10. 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?

  11. 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?

  12. 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.

  13. 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 like parse($thing), so that textpattern processes the value.

  14. 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?

  15. 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.

  16. 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 ;-)

  17. 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.

  18. 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.)

Don't be shy, you can comment too!

Some things to keep in mind: You can style comments using Textile. In particular, *text* will get turned into text and _text_ will get turned into text. You can post a link using the command "linktext":link, so something like "google":http://www.google.com will get turned in to google. I may erase off-topic comments, or edit poorly formatted comments; I do this very rarely.