Jump to:

23490 Posts in 18996 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » How to get rid of "Your website URL" field in post comment form

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 2654 Views
  • mango
    Avatar
    Community Member
    26 Posts

    How to get rid of "Your website URL" field in post comment form Link to this post

    Is there a way to get rid of "Your website URL" field in the post comment form without making changes to cms/code/sitefeatures/PageCommentInterface.php?

  • PGiessler
    Avatar
    Community Member
    47 Posts

    Re: How to get rid of "Your website URL" field in post comment form Link to this post

    Hi

    Go the PageComments class and delete this field in the Contoller. So this field won't be visible for anyone. I don't have enough time, to give you the whole path.

    Best regards,

    Pascal

  • mango
    Avatar
    Community Member
    26 Posts

    Re: How to get rid of "Your website URL" field in post comment form Link to this post

    I'm looking for a solution without doing any changes to the code. Introducing solution in code is not ideal since it might disappear upon next update.

  • PGiessler
    Avatar
    Community Member
    47 Posts

    Re: How to get rid of "Your website URL" field in post comment form Link to this post

    Hi mango,

    I read currently my last post and I have to detect, that my statement was very difficult to understand. Sorry. What I mean is that
    you can write in your Page.php file or another php file. So you can overwrite the pagecomments, because you have a relation with methods on other class.

    Best regards,

    Pascal

  • mango
    Avatar
    Community Member
    26 Posts

    Re: How to get rid of "Your website URL" field in post comment form Link to this post

    Pascal, thanks for the pointer, I now understand what you mean. I guess I'll have to learn a bit more before overwriting pagecomments' behaviour. For the time being I'll just use CSS to display:none it.

    Thanks again.

  • orion
    Avatar
    Community Member
    20 Posts

    Re: How to get rid of "Your website URL" field in post comment form Link to this post

    I have a project where I need to upload text content to some pages of an unfinished site, while developing the rest of it. My concern is that when i update the site, will I overwrite all my content. Is there a way I can prevent this?

    Thank you in advance!

  • CHD
    Avatar
    Community Member
    218 Posts

    Re: How to get rid of "Your website URL" field in post comment form Link to this post

    i always use this to remove the URL field....

    #CommenterURL {
    display:none;
    }

  • Myrdhin
    Avatar
    Community Member
    67 Posts

    Re: How to get rid of "Your website URL" field in post comment form Link to this post

    or you can :

    1 - Create a file mysite/code/PageCommentInterfaceWithoutURL.php :

    <?php

    class PageCommentInterfaceWithoutURL extends PageCommentInterface{

       function PostCommentForm() {
          $form = parent::PostCommentForm();
          $fields = $form->Fields();
          $fields->removeByName('CommenterURL');
          $form->setFields($fields);
          return $form;
       }
    }

    ?>

    2 - and add this function in your Page_Controller class in mysite/code/page.php :

    function PageComments() {
       if($this->data() && $this->data()->ProvideComments) {
          return new PageCommentInterfaceWithoutURL($this, 'PageComments', $this->data());
       }
       else {
          if(isset($_REQUEST['executeForm']) && $_REQUEST['executeForm'] == 'PageComments.PostCommentForm') {
             echo "Comments have been disabled for this page";
             die();
          }
       }
    }

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