CoreCommunity ExtensionsIncubatorDistributionsTYPO3 4.5 ProjectsTYPO3 4.6 ProjectsTYPO3 4.7 ProjectsTYPO3 6.0 ProjectsTYPO3 6.1 ProjectsTYPO3 6.2 Projects (+)

Feature #32155

Pagination widget: Add total number of news items to pagination object

Added by Steffen Müller over 1 year ago. Updated about 1 year ago.

Status:Resolved Start date:2011-11-29
Priority:Should have Due date:
Assignee:Georg Ringer % Done:

100%

Category:Frontend
Target version:1.4.0
TYPO3 Version:4.5 Has patch:No
PHP Version: Complexity:
Votes: 1 (View)

Description

Those who like to show the total number of news items in the paginator, would need a new property {pagination.numberOfItems}

This could be added easily to function buildPagination():

$pagination = array(
...
  'numberOfItems' => count($this->objects),
...

Is this already possible otherwise? If no, I'd push the changes to gerrit.

Associated revisions

Revision 60998478
Added by Georg Ringer over 1 year ago

[FEATURE] Improve pagination

New items:
- numberOfItems: number of all news records
- firstPageItem: number of first news item which is currently displayed
- lastPageItem: number of last news item which is currently displayed

Now it is possible to display the information like
"shown currently news 19 - 26 of 700 totals"

Change-Id: I15ae4bdbff974b6d4e20125f6b988c63de53001c
Resolves: #32155

History

Updated by Steffen Müller over 1 year ago

And there's some more information which could be interesting in the widget.

Imagine a paginator showing you the number of shown items and the total number of news items:

News 1-10 of 256
11-20 of 256
...

This could be made available via:

{pagination.firstPageItem}
{pagination.lastPageItem}

WidgetController:

$pagination['firstPageItem'] = ($this->currentPage - 1) * (integer)$this->configuration['itemsPerPage'] + 1;

if ($this->currentPage < $this->numberOfPages) {
  $pagination['nextPage'] = $this->currentPage + 1;
  $pagination['lastPageItem'] = $this->currentPage * (integer)$this->configuration['itemsPerPage'];
 } else {
  $pagination['lastPageItem'] = count($this->objects);
}

I'll go push that :)

Updated by Georg Ringer over 1 year ago

count can be done in fluid, see searchresult.html

<f:translate key="search-text" arguments="{0:'{f:count(subject:news)}',1:search.subject}" />

but if you add it with the others, it is fine too I guess

Updated by Steffen Müller over 1 year ago

I'd also add another language label for that. How is the translation handled?

Updated by Georg Ringer over 1 year ago

just add it to locallang or what do you mean?

Updated by Steffen Müller over 1 year ago

Add default language is clear. What about translations? Are they manually put into the locallang.xml file or via translation server? I could add german version too if it's done manually.

Updated by Steffen Müller over 1 year ago

What is the policy for handling new properties in templates?

Three new properties would be made available in paginator template.

a) Adding them to template would break existing sites, which use unchanged extension templates instead of copies from fileadmin/
b) Adding them not to template would not demonstrate the usage.

I'd choose a), since templating best practice is to always use a copy in fileadmin instead of extension original.

Updated by Georg Ringer over 1 year ago

why should there something break? i didn't get it, but we can just add breaking changes to the wiki and later to the manual as I did with 1.2.0.

nevertheless, push the change and I will check it anyways ;)

Updated by Steffen Müller over 1 year ago

If we add this to the paginate widget template of the extension:

Item {pagination.firstPageItem} to {pagination.lastPageItem} of {pagination.numberOfItems}

Then anyone who uses the paginate widget will get some new content in hoer website after upgrade:

Item 1 to 10 of 145

Btw. Is there a TS configuration to set custom path to widget template?
I tried:

plugin.tx_news.view {
  widget.Tx_News_ViewHelpers_Widget_PaginateViewHelper.templateRootPath = fileadmin/news-tmpl/Templates/
}

The file itself is placed in: fileadmin/news-tmpl/Templates/ViewHelpers/Widget/Paginate/Index.html

but it didn't work. Could find any info in the wiki or ext docs.

Updated by Josef Florian Glatz over 1 year ago

Im running the master von git and it works for me with the following code:
I'd also problems with it, but it was an caching problem. I had to manually clear cache, config.no_cache didn't works here for me - I don't know why...

1 plugin.tx_news {
2     view {
3         templateRootPath = {$fw.path.htmlext}news/textblog/Templates/
4         partialRootPath = {$fw.path.htmlext}news/textblog/Partials/
5         layoutRootPath = {$fw.path.htmlext}news/textblog/Layouts/
6         widget.Tx_News_ViewHelpers_Widget_PaginateViewHelper.templateRootPath = {$fw.path.htmlext}news/textblog/Templates/
7     }
8 }

Updated by Steffen Müller over 1 year ago

You have to apply a patch in TYPO3 4.5 to be able to configure a custom widget template.

When we change the paginate widget template, all unpatched 4.5 installations will use the changed template. For most installations, adding new properties is a breaking change.

We need a decision :)

Updated by Gerrit Code Review over 1 year ago

Patch set 1 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/8734

Updated by Gerrit Code Review over 1 year ago

Patch set 2 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/8734

Updated by Georg Ringer over 1 year ago

  • Status changed from New to Resolved
  • Assignee set to Georg Ringer
  • Target version set to 1.4.0
  • % Done changed from 0 to 100

thx for the patch. now included. locallangs are not changed as I guess it has to be changed anyway for every project ... still info should be updated in wiki or manual I guess ;)

Updated by Steffen Müller over 1 year ago

What about adding a "showcase template" for demonstration, with a big fat warning not to use it in production.

Also available in: Atom PDF