Blog comments form

edited November 2013 in Modules
Is it possible to use my own form rather than the form_builder form for the blog comments?

I've already tried replacing <?=$comment_form?> with my own form, using
<?php echo site_url($this->uri->uri_string()).'#comments_form';?> as the form action and using <?php echo $post->id;?> as the post_id, but have had no luck.

Comments

  • edited 2:48PM
    What is happening instead? Is it perhaps that the "antispam" hidden field isn't set? The value of that is stored in the session:
    $this->session->userdata('antispam');

    Also, the blog config file allows you to set additional fields as well as pass any sort of Form_builder parameters to it with the "comment_form" config in that file.
  • edited 2:48PM
    Strangely enough I did think I shouldnt be so lazy, and had read up a little on codeigniter and managed to make the changes i needed. My only questions are though;

    Can i set $render_format = 'divs' for only the blog comments form? I made the change in the form_builder but it sets it globally.

    I was able to change the div class that wraps the labels and inputs, by changing $str .= " class=\"field\">"; within the form_builder. Can/should this be done for the blog only?
  • edited November 2013
    I've figured out how to override the form_builder parameters, and how to pass additional attributes to the input elements. But 'placeholder' => 'some text here' doesnt seem to work.

    I also cant see where to add additional attributes to the labels either.
  • edited 2:48PM
    For the $render_form = 'divs', if you are using the 1.0 beta, you can create a fuel/application/config/blog.php file and add the following or you can just add it to the fuel/modules/blog/config/blog.php file in 0.93:
    $config['blog']['comment_form']['render_format'] = 'divs';
    The same applies to the $fields:
    $config['blog']['comment_form']['fields'] = array('author_name' => array('label' => 'Name', 'required' => TRUE, 'class' => 'myclass'),....);
  • edited 2:48PM
    Thanks. I did eventually figure it out. However 'placeholder' => 'myplaceholder' doesn't seem to be supported though
  • edited 2:48PM
    Are you using .93 or 1.0 beta?
  • edited 2:48PM
    .93
  • edited 2:48PM
    Ah... placeholder isn't an option in .93. 1.0 beta includes it though but also has it as a separate module that needs to be installed:
    https://github.com/daylightstudio/FUEL-CMS-Blog-Module
  • edited 2:48PM
    Thanks.
  • edited 2:48PM
    Hello,
    I'm on a similar problem. I've managed to do what was mentioned above, but cannot figure out what to do with the submit button and the paragraph texts in the form (I want to change them).
    Can you pls help?
  • edited 2:48PM
    The $config['blog']['comment_form'] value in fuel/modules/blog/config/blog.php can be an array of initialization values for the Form_builder instance used to render the comment form:
    http://docs.getfuelcms.com/libraries/form_builder
    $config['blog']['comment_form']['submit_value'] = 'Submit Form'; $config['blog']['comment_form']['fields'] = array('new_comment' => array('type' => 'text', 'class' => 'my_class'...));
    The comment form is passed the $form variable and uses the views/themes/default/_blocks/comment_form.php view file, however, you don't have to use it and can use your own form as long as it has the following fields:
    author_name
    author_email
    new_comment
    post_id
  • edited 2:48PM
    Thanks!
    I am changing all the view files to make my own template, but I am stuck with the comment_form.php. All it has is one line: <?=$form?> and I cannot track back where the view is actually customizable. Anything I put in that file is not displayed.
  • edited 2:48PM
    Are comments enabled for the posts? This is both in the Blog Settings in the CMS as well as on a per post basis. The views/themes/default/post.php file around line 48 has a condition check with if $post->allow_comments.
  • edited January 2016
    Yes, they are. I can see the comments and the comment form under the blog post.
    It's just that it seems it is not the comment_form.php file that is actually controls how the comment form is displayed on the post page. Nothing I put there gets displayed.
    Is there some other setting for switching it on and off?
  • edited 2:48PM
    You can debug the blog_posts_model.php file and look at line 656 or so at the "get_allow_comments" method. This should return a boolean value based on the blog config, the blog settings in the CMS, and the blog_posts record itself. $this->_CI->fuel->blog->config('allow_comments') looks at first the blog config and then merges it with any settings saved in the CMS (under the Settings > Blog).
  • edited 2:48PM
    Thanks for your help.
    1. I'm really confused about this views/themes/default/_blocks/comment_form.php file. Even if I delete it, the comment form still gets displayed. Nothing I do with it has any affect on my comment form.
    2. Nevertheless, I have now managed to style my comment form through fuel/modules/blog/config/blog.php. BUT. I still cannot manage to add css to the submit button. (I want to add bootstrap classes).
    I was trying to use the css array() property, but no luck. Can you advise how to do it? This is how i tried:
    $config['blog']['comment_form']['css'] = array(
    'Submit' => 'btn btn-primary'
    );
  • edited 2:48PM
    1. This looks to be a bug with the 1.1 update. I've pushed a fix for it here:
    https://github.com/daylightstudio/FUEL-CMS-Blog-Module/commit/98ebd10544ac815097fe838f6a467f5bca52164c
    2. Unfortunately, you can't style the Submit button with the auto generated comment form.
  • edited January 2016
    deleted
  • edited 2:48PM
    I have updated my blog module and now it seems that views/themes/default/post.php does not have any affect on how the post looks. The same way as the comment_form.php before. Can you pls look into it?
  • edited 2:48PM
    Also, hitting Reply on a comment loads the whole page into the container instead of the comment form.
  • edited 2:48PM
    Is there another theme that it's pulling from (e.g. another post.php file that it may be pulling from). Also, for the comment reply try adding the following javascript file (located at fuel/modules/blog/assets/comment_reply.js) to your blog layout:
    <?=js('comment_reply', 'blog')?>
  • edited 2:48PM
    Also, I was seeing an error where the Session library wasn't loaded so this fix was just posted.
    https://github.com/daylightstudio/FUEL-CMS-Blog-Module/commit/d35a23970cfe20ad9591c66e9a5e5695e9f4cd73
  • edited 2:48PM
    1. i have 3 different themes. I've checked many times if i was changing the right one. It is the same with all of them: even if i remove the post.php, the post gets displayed. Just like it was with the comment_form before.
    2. I have tried, no luck. It seems this link points to the main blog page:
    href="<?=$this->fuel->blog->url('comment_reply/'.$comment->id)?>"
    (I do have the comment_reply.js in the assets folder.)
    3. One more: The FUEL bar at the top gets hidden under my navbar, so i can never see it. Can i do anything about it?
  • edited 2:48PM
    1. What is the Blog URI in which you are seeing this problem? Also, what does the following output?
    <?=$this->fuel->blog->theme_path();?>
    2. What version of the blog module are you using (you can check the fuel/modules/blog/config/blog_constants.php):
    https://github.com/daylightstudio/FUEL-CMS-Blog-Module/tree/master/assets/js
    3. You'll need to set your header to below a z-index of 999
  • edited 2:48PM
    1. I have reinstalled it, so now #1 is solved.
    2. Version 1.1. Just downloaded the full pack again yesterday. Reinstalled today. Now all I have there is the default theme, I have not customized anything and the reply form still loads the main page into the reply form container. That path url('comment_reply/'.$comment->id) does not seem to work.
  • edited 2:48PM
    Are you seeing any javascript errors? It uses AJAX to work and requires jQuery.
  • edited 2:48PM
    Only a warning that getPreventDefault() deprecated.
    I'm not sure if I'm looking at the right thing, but this line looks okay:
    GET XHR http://localhost/OKGY/blog/comment_reply/2
    but that link points to the main blog page, so that is what is loaded - in place of the reply form.
    Okay, I may just omit the reply part, that's not a big problem.
    What is a big problem though is the blog pictures don't get displayed. They're 404:
    x GET http://localhost/OKGY/blog/2016/01/14/img/szikla.png [HTTP/1.1 404 Not Found ]
    The blog images are located at assets/images/blog. It is the same setting in the CMS. Do I need to set something to get the right path?
  • edited 2:48PM
    For the post images, there is an "asset_upload_path" blog setting that by default is set to "images/blog". How are you referencing the image path in your post template (e.g. $post->image_path)?
Sign In or Register to comment.