Skip to content

Commit

Permalink
[FEATURE] Make pagination configurable (#34)
Browse files Browse the repository at this point in the history
Releases: master, 9.1
  • Loading branch information
benjaminkott committed Feb 14, 2019
1 parent 2476717 commit 461db54
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 21 deletions.
10 changes: 10 additions & 0 deletions Configuration/TypoScript/Static/constants.typoscript
Expand Up @@ -49,6 +49,16 @@ plugin {
storagePid = 0

lists {
pagination {
# cat=blog/blog_120_lists; type=int+; label= LLL:EXT:blog/Resources/Private/Language/locallang.xlf:constantEditor.lists.pagination.itemsPerPage
itemsPerPage = 10
# cat=blog/blog_120_lists; type=int+; label= LLL:EXT:blog/Resources/Private/Language/locallang.xlf:constantEditor.lists.pagination.insertAbove
insertAbove = 0
# cat=blog/blog_120_lists; type=int+; label= LLL:EXT:blog/Resources/Private/Language/locallang.xlf:constantEditor.lists.pagination.insertBelow
insertBelow = 1
# cat=blog/blog_120_lists; type=int+; label= LLL:EXT:blog/Resources/Private/Language/locallang.xlf:constantEditor.lists.pagination.maximumNumberOfLinks
maximumNumberOfLinks = 10
}
posts {
# cat=blog/blog_120_lists; type=int+; label= LLL:EXT:blog/Resources/Private/Language/locallang.xlf:constantEditor.lists.posts.maximumDisplayedItems
maximumDisplayedItems = 0
Expand Down
6 changes: 6 additions & 0 deletions Configuration/TypoScript/Static/setup.typoscript
Expand Up @@ -32,6 +32,12 @@ plugin.tx_blog {
}
# Lists related settings
lists {
pagination {
itemsPerPage = {$plugin.tx_blog.settings.lists.pagination.itemsPerPage}
insertAbove = {$plugin.tx_blog.settings.lists.pagination.insertAbove}
insertBelow = {$plugin.tx_blog.settings.lists.pagination.insertBelow}
maximumNumberOfLinks = {$plugin.tx_blog.settings.lists.pagination.maximumNumberOfLinks}
}
posts {
maximumDisplayedItems = {$plugin.tx_blog.settings.lists.posts.maximumDisplayedItems}
dateFormat = {$plugin.tx_blog.settings.lists.posts.dateFormat}
Expand Down
12 changes: 12 additions & 0 deletions Resources/Private/Language/locallang.xlf
Expand Up @@ -324,6 +324,18 @@
<trans-unit id="constantEditor.CommentAddedNotification.admin.email" xml:space="preserve">
<source>Admin mail:Global admin (receiver) email address for notifications</source>
</trans-unit>
<trans-unit id="constantEditor.lists.pagination.itemsPerPage" xml:space="preserve">
<source>Number of post that should be displayed per page</source>
</trans-unit>
<trans-unit id="constantEditor.lists.pagination.insertAbove" xml:space="preserve">
<source>Show the pagination above the posts</source>
</trans-unit>
<trans-unit id="constantEditor.lists.pagination.insertBelow" xml:space="preserve">
<source>Show the pagination below the posts</source>
</trans-unit>
<trans-unit id="constantEditor.lists.pagination.maximumNumberOfLinks" xml:space="preserve">
<source>Maximum number of links in the pagination</source>
</trans-unit>
<trans-unit id="constantEditor.lists.posts.maximumDisplayedItems" xml:space="preserve">
<source>Maximum displayed items:Maximum number of posts to be displayed (0 = no limit).</source>
</trans-unit>
Expand Down
39 changes: 18 additions & 21 deletions Resources/Private/Partials/List.html
@@ -1,28 +1,25 @@
<div class="tx-blog-post-list {class}" xmlns:f="http://www.w3.org/1999/html" xmlns:blog="http://typo3.org/ns/T3G/AgencyPack/Blog/ViewHelpers">
<f:alias map="{paginateItemsPerPage: 10}">
<f:if condition="{posts}">
<f:then>
<f:if condition="{posts->f:count()} > {paginateItemsPerPage}">
<f:then>
<f:render section="PaginatePosts" arguments="{posts: posts, itemsPerPage: paginateItemsPerPage}" />
</f:then>
<f:else>
<f:render section="ListPosts" arguments="{posts: posts}" />
</f:else>
</f:if>
</f:then>
<f:else>
<div class="alert alert-info" role="alert">
<strong><f:translate key="list.no_posts.title" /></strong><br/><f:translate key="list.no_posts.message" />
</div>
</f:else>
</f:if>
</f:alias>
<f:if condition="{posts}">
<f:then>
<f:if condition="{posts->f:count()} > {settings.lists.pagination.itemsPerPage}">
<f:then>
<f:render section="PaginatePosts" arguments="{posts: posts, pagination: settings.lists.pagination}" />
</f:then>
<f:else>
<f:render section="ListPosts" arguments="{posts: posts}" />
</f:else>
</f:if>
</f:then>
<f:else>
<div class="alert alert-info" role="alert">
<strong><f:translate key="list.no_posts.title" /></strong><br/><f:translate key="list.no_posts.message" />
</div>
</f:else>
</f:if>
</div>

<f:section name="PaginatePosts">
<f:widget.paginate objects="{posts}" as="paginatedPosts"
configuration="{itemsPerPage: itemsPerPage, insertAbove: 0, insertBelow: 1, addQueryStringMethod: 'GET', maximumNumberOfLinks: 10}">
<f:widget.paginate objects="{posts}" as="paginatedPosts" configuration="{itemsPerPage: pagination.itemsPerPage, insertAbove: pagination.insertAbove, insertBelow: pagination.insertBelow, maximumNumberOfLinks: pagination.maximumNumberOfLinks}">
<f:render section="ListPosts" arguments="{posts: paginatedPosts}" />
</f:widget.paginate>
</f:section>
Expand Down

0 comments on commit 461db54

Please sign in to comment.