Allow comments to work fine on Form 2.0 too
This commit is contained in:
parent
61b7cd43d1
commit
9ade9bb637
|
@ -1,8 +1,10 @@
|
|||
# v1.2.x
|
||||
## 08/xx/2016
|
||||
## 09/xx/2016
|
||||
|
||||
1. [](#improved)
|
||||
* Added Croatian translation
|
||||
1. [](#bugfix)
|
||||
* Fix [#35](https://github.com/getgrav/grav-plugin-comments/issues/35) Allow comments to work fine on Form 2.0 too
|
||||
|
||||
# v1.2.2
|
||||
## 08/12/2016
|
||||
|
|
25
comments.php
25
comments.php
|
@ -31,6 +31,10 @@ class CommentsPlugin extends Plugin
|
|||
|
||||
/**
|
||||
* Initialize form if the page has one. Also catches form processing if user posts the form.
|
||||
*
|
||||
* Used by Form plugin < 2.0, kept for backwards compatibility
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function onPageInitialized()
|
||||
{
|
||||
|
@ -49,8 +53,26 @@ class CommentsPlugin extends Plugin
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the comment form information to the page header dynamically
|
||||
*
|
||||
* Used by Form plugin >= 2.0
|
||||
*/
|
||||
public function onFormPageHeaderProcessed(Event $event)
|
||||
{
|
||||
$header = $event['header'];
|
||||
|
||||
if ($this->enable) {
|
||||
if (!isset($header->form)) {
|
||||
$header->form = $this->grav['config']->get('plugins.comments.form');
|
||||
}
|
||||
}
|
||||
|
||||
$event->header = $header;
|
||||
}
|
||||
|
||||
public function onTwigSiteVariables() {
|
||||
$this->grav['twig']->enable = $this->enable;
|
||||
$this->grav['twig']->enable_comments_plugin = $this->enable;
|
||||
$this->grav['twig']->comments = $this->fetchComments();
|
||||
}
|
||||
|
||||
|
@ -97,6 +119,7 @@ class CommentsPlugin extends Plugin
|
|||
$this->enable([
|
||||
'onTwigTemplatePaths' => ['onTwigTemplatePaths', 0],
|
||||
'onFormProcessed' => ['onFormProcessed', 0],
|
||||
'onFormPageHeaderProcessed' => ['onFormPageHeaderProcessed', 0],
|
||||
'onPageInitialized' => ['onPageInitialized', 10],
|
||||
'onTwigSiteVariables' => ['onTwigSiteVariables', 0]
|
||||
]);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% if grav.twig.enable %}
|
||||
{% if grav.twig.enable_comments_plugin %}
|
||||
|
||||
<h3>{{'PLUGIN_COMMENTS.ADD_COMMENT'|t}}</h3>
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% include "forms/fields/formname/formname.html.twig" %}
|
||||
|
||||
<div class="buttons">
|
||||
{% for button in grav.config.plugins.comments.form.buttons %}
|
||||
|
|
Loading…
Reference in New Issue