Skip to content

Commit

Permalink
[!!!][TASK] Add configuration error note for single view plugins (#94)
Browse files Browse the repository at this point in the history
To prevent the usage of plugins that should only be
used on post views we are now adding additional 
checks for those. If no post could be resolved - also 
means if the plugin is used on pages that do not match
the `Constants::DOKTYPE_BLOG_POST` - the plugins will
now return a new message to make the miss usage visible.

```
A possible configuration error was detected.
No matching post could be obtained. 
Make sure that this plugin is only used on a post.
```

The following plugins will now show this message if no 
post could be obtained:
* Authors
* Footer
* Header
* Metadata
* RelatedPosts

Templates added:
* Layouts/Post.html

Templates changed:
* Templates/Comment/Comments.html
* Templates/Comment/Form.html
* Templates/Post/Authors.html
* Templates/Post/Footer.html
* Templates/Post/Header.html
* Templates/Post/Metadata.html
* Templates/Post/RelatedPosts.html

Releases: master
  • Loading branch information
benjaminkott authored Aug 7, 2019
1 parent 48d408d commit 780f018
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 20 deletions.
1 change: 1 addition & 0 deletions Classes/Controller/CommentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public function commentsAction(): void
$this->blogCacheService->addTagToPage('tx_blog_comment_' . $comment->getUid());
}
$this->view->assign('comments', $comments);
$this->view->assign('post', $post);
}
}
}
2 changes: 1 addition & 1 deletion Classes/Controller/PostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ public function relatedPostsAction(): void
(int)$this->settings['relatedPosts']['limit']
);
$this->view->assign('type', 'related');
$this->view->assign('currentPost', $post);
$this->view->assign('post', $post);
$this->view->assign('posts', $posts);
}

Expand Down
8 changes: 8 additions & 0 deletions Resources/Private/Language/locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
<header/>
<body>

<!-- General -->
<trans-unit id="general.message.configuration_error.title" xml:space="preserve">
<source>A possible configuration error was detected.</source>
</trans-unit>
<trans-unit id="general.message.configuration_error.single_no_post" xml:space="preserve">
<source>No matching post could be obtained. Make sure that this plugin is only used on a post.</source>
</trans-unit>

<!-- Headline -->
<trans-unit id="headline.commentform" xml:space="preserve">
<source>Write comment</source>
Expand Down
13 changes: 13 additions & 0 deletions Resources/Private/Layouts/Post.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<f:spaceless>
<f:if condition="{post}">
<f:then>
<f:render section="Content" />
</f:then>
<f:else>
<div class="alert alert-danger" role="alert">
<div class="alert__title"><f:translate key="general.message.configuration_error.title"/></div>
<div class="alert__message"><f:translate key="general.message.configuration_error.single_no_post"/></div>
</div>
</f:else>
</f:if>
</f:spaceless>
7 changes: 5 additions & 2 deletions Resources/Private/Templates/Comment/Comments.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<f:spaceless>
<f:layout name="Post" />
<f:section name="Content">

<f:if condition="{settings.comments.active}">
<div class="postcomments">
<h3 class="postcomments__title" id="comments"><f:translate key="headline.comments"/></h3>
Expand All @@ -18,4 +20,5 @@ <h3 class="postcomments__title" id="comments"><f:translate key="headline.comment
</f:if>
</div>
</f:if>
</f:spaceless>

</f:section>
21 changes: 13 additions & 8 deletions Resources/Private/Templates/Comment/Form.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
<f:if condition="{post} && {settings.comments.active}">
<div class="postcommentsform" id="postcommentform-{post.uid}">
<f:variable name="formName" value="Local" />
<f:if condition="{settings.comments.disqus._typoScriptNodeValue}"><f:variable name="formName" value="Disqus" /></f:if>
<f:if condition="{post.commentsActive}"><f:else><f:variable name="formName" value="Closed" /></f:else></f:if>
<f:render partial="Comments/Form/{formName}" arguments="{_all}" />
</div>
</f:if>
<f:layout name="Post" />
<f:section name="Content">

<f:if condition="{post} && {settings.comments.active}">
<div class="postcommentsform" id="postcommentform-{post.uid}">
<f:variable name="formName" value="Local" />
<f:if condition="{settings.comments.disqus._typoScriptNodeValue}"><f:variable name="formName" value="Disqus" /></f:if>
<f:if condition="{post.commentsActive}"><f:else><f:variable name="formName" value="Closed" /></f:else></f:if>
<f:render partial="Comments/Form/{formName}" arguments="{_all}" />
</div>
</f:if>

</f:section>
7 changes: 5 additions & 2 deletions Resources/Private/Templates/Post/Authors.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<f:spaceless>
<f:layout name="Post" />
<f:section name="Content">

<f:if condition="{post.authors}">
<div class="postauthors">
<f:for each="{post.authors}" as="author">
<f:render partial="Post/Author" arguments="{_all}" />
</f:for>
</div>
</f:if>
</f:spaceless>

</f:section>
7 changes: 5 additions & 2 deletions Resources/Private/Templates/Post/Footer.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<f:spaceless>
<f:layout name="Post" />
<f:section name="Content">

<footer class="postfooter">
<f:if condition="{settings.meta.postfooter.enable}">
<div class="postfooter__meta">
<f:render partial="Meta/PostFooter" arguments="{_all}" />
</div>
</f:if>
</footer>
</f:spaceless>

</f:section>
7 changes: 5 additions & 2 deletions Resources/Private/Templates/Post/Header.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<f:spaceless>
<f:layout name="Post" />
<f:section name="Content">

<header class="postheader">
<h1 class="postheader__title">{post.title}</h1>
<f:if condition="{settings.meta.postheader.enable}">
Expand All @@ -7,4 +9,5 @@ <h1 class="postheader__title">{post.title}</h1>
</div>
</f:if>
</header>
</f:spaceless>

</f:section>
7 changes: 5 additions & 2 deletions Resources/Private/Templates/Post/Metadata.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<f:spaceless>
<f:layout name="Post" />
<f:section name="Content">

<f:render partial="Meta/Default" arguments="{_all}" />
</f:spaceless>

</f:section>
4 changes: 3 additions & 1 deletion Resources/Private/Templates/Post/RelatedPosts.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<f:layout name="Default" />
<f:layout name="Post" />
<f:section name="Content">

<f:render partial="SimpleList" arguments="{_all}" />

</f:section>

0 comments on commit 780f018

Please sign in to comment.