Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Creating an "Edit this Page" link

Go to End

3 Posts   3169 Views


Community Member, 19 Posts

3 January 2009 at 4:41am

I am trying to create an edit this page link for clients who find it easier to navigate through the site, and find what they want to edit rather than going through the admin interface.

I tried snipping some code from the blog module which has the ability to do so, but it just takes me to the parent page rather than any sort of edit page.

In the page.php I have added the function...

function EditURL(){
return $this->getParent()->Link('post')."/".$this->ID."/";

under-> class Page extends SiteTree {

Then had the following code in the template

<% if CurrentMember %><p><a href="$EditURL" id="editpost" title="Edit this page">Edit this page</a> | <a href="$Link(unpublishPost)" id="unpublishpost">Unpublish this page</a></p><% end_if %>

What do I seem to be missing?


Forum Moderator, 4102 Posts

3 January 2009 at 6:28am

Well you haven't set up any code or template for the /post/ action.

in your controller, add

static $allowed_actions = array ('post');

function EditForm()
return new Form(
new FieldSet(new FormAction('save','Save'))

function save($data,$form)
// handle the posted data

then you need to make

and add $EditForm to that template

you get the idea..


Community Member, 19 Posts

5 January 2009 at 9:16am

Sounds like that is a bit more advanced than I was planning, but I like the idea. That might be something I do when I get more time, I was able to make a simple "link to the admin area" link using the following code...

function EditURL(){
return "/admin/show/".$this->ID."/";