Jump to:

5540 Posts in 1738 Topics by 1224 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Creating an "Edit this Page" link

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

Page: 1
Go to End
Author Topic: 1940 Views
  • 3pointross
    Avatar
    Community Member
    18 Posts

    Creating an "Edit this Page" link Link to this post

    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?

  • UncleCheese
    Avatar
    4085 Posts

    Re: Creating an "Edit this Page" link Link to this post

    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(
    $this,
    "EditForm"
    $some_fieldset,
    new FieldSet(new FormAction('save','Save'))
    );
    }

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

    then you need to make YourPage_post.ss

    and add $EditForm to that template

    you get the idea..

  • 3pointross
    Avatar
    Community Member
    18 Posts

    Re: Creating an "Edit this Page" link Link to this post

    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."/";
       }

    1940 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.