How to custom display numbers in CakePHP Paginator - cakephp

I'm trying to change the display of links on a search result page.This is how the links display on my page:
1 2 3 4 5 6 7 8 9 10 | Next10
1 is current page.
After clicked on Next10 link, I want it display like this:
11 12 13 14 15 16 17 18 19 20 | Next10
I 've spend hours on it. But I couldn't find the way to make it work. Is there any solution?
I use
'echo $this->Paginator->link('Next10',array('page' => $this->Paginator->params('page') + 11));'
for the view.

You're going to have to write your own paginator function to display the numbers. What you're after (and what Cake doesn't support) is a different modulus for pages before and after the displayed page. Cake only supports one modulus argument:
http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html#creating-page-number-links

Related

Draw arrow in WPF

I wanted to draw the arrow with element. Is there any way to do that or any tools which autogenerate the path for given shape ?
https://stackoverflow.com/a/30477088/15720206 , I needed arrow which is different than the above post.
reference googled picture:
https://www.google.com/search?q=arrow+head+symbol&safe=active&rlz=1C1GCEB_enIN859IN859&sxsrf=ALeKk0306SSwnBsHVElNz35YJeOstlWwsQ:1629698889584&source=lnms&tbm=isch&sa=X&ved=2ahUKEwj94Z27vcbyAhWO_3MBHUp4CMIQ_AUoAXoECAEQAw&biw=1918&bih=952#imgrc=wv3eg9wV_H09FM
I found the answer: following use of data points will solve:
Data="M 0 10 10 10 10 7.5 15 11 10 14.5 10 12 0 12 Z"

Add offset to current page number in Winforms ReportViewer

I am working with the Winforms ReportViewer and I have the following problem: I would like to modify the start index for the page number.
For example, I have 3 reports, each one consists of 2 pages.
By using the expression: "Globals!PageNumber" I will get the current page number and "Globals!TotalPages" I will get the number of pages for each report. So the result will look like this:
Report 1: Page 1 of 2, Page 2 of 2
Report 2: Page 1 of 2, Page 2 of 2
Report 3: Page 1 of 2, Page 2 of 2
However, I would like to modify this into the following:
Report 1: Page 1 of 6, Page 2 of 6
Report 2: Page 3 of 6, Page 4 of 6
Report 3: Page 5 of 6, Page 6 of 6
The expression "Globals!TotalPages" can just be replaced by a constant (in this case number 6), that's not a problem.
However, regarding the current page number, I would have to add an offset to "Globals!PageNumber", for example for report 2: "Globals!PageNumber" + 2
Unfortunately, this does not work, because the expression "Globals!PageNumber" is only evaluated once the report has been created.
Is there a possibility to add an offset to the current page number?
Thanks in advance for any advice.
You have to put a TextBox in footer/header to use an expression like this:
=Globals!PageNumber + 2

print no of items fetched using pagination in cakephp 3

I want to display count of no of items fetched per page using pagination like
Displaying 10 items
Although limit is set to pagination to 20 but It will not always fetch 20 items when there are only 15 items or 10 items or 25 items.
In these cases it will either have one page result for items count 15 and 10 or two pages result for items count 25.
I want to print the no of items showing on each page. Like for total items 25.
It will show Displaying 20 items on first page and Displaying 5 items on second page.
How is it possible in CakePHP 3.2 ?
This is how I get it working in CakePHP 3.2
There are two ways you can do it.
Using Helpers
create a file paginator-counter.php in /config directory with your tokens and string and add a line in /src/view/AppView.php
public function initialize()
{
$this->loadHelper('Paginator', ['templates' => 'paginator-counter']);
}
This will load the file located at config/paginator-templates.php
And then use it in your view.
For more : http://book.cakephp.org/3.0/en/views/helpers/paginator.html
Using direct string
Just print in view where you want to print the counter
<?= $this->Paginator->counter('Showing {{current}} results out of {{count}}') ?>
More tokens can be found Here : http://book.cakephp.org/3.0/en/views/helpers/paginator.html#creating-a-page-counter
I'm using 2nd way to print counter ie., using sting directly

Cakephp LImiting Pagination Counter

I want to limit the counter that is visible in pagination in cakephp? What should I do...? Currently its default showing as 1-9 as pages link. I tried limit but as it limits my post per page. I want to limit the counter not post per page. Please help me.
Modified...
I tried modulus according to answers..
I want my Pagination should be this way. If it is on first Page then.
1 2 3 ... Last
If it is on Middle of page then..
First ... 6 7 8 ... Last
If it it on last then.
First ... 11 12 13
My tried code is.
<?php echo $this->Paginator->numbers(array('modulus' => '2', 'tag' => 'span','first'=>'First','ellipsis'=>'...', 'separator' => ' ', 'last'=>'Last' )); ?>
Check out the documentation for the pagination helper: http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html
I think want you want is "modulus - how many numbers to include on either side of the current page, defaults to 8."
So in your View, you'd have something like:
// Limit numbers to 4 either side of current page
echo $this->Paginator->numbers(array('modulus' => 4));
Hope that helps.

How can I paginate like: Prev 4 5 6 7 Next

I have a problem with this paginate in Cakephp. Please show me how to do this!
My problem is:
+ In normal: the page numbers are:
Prev 1 2 3 4 Next
When user press from 1 to 4, the page numbers are not changed.
When user press the Next button, I want the page numbers must be:
Prev 5 6 7 8 Next
But now they are:
Prev 3 4 5 6 Next
How can I move the number 5 leftmost when I press the Next button
I'm using the $this->Paginator->numbers to generate page number, how can I config this?
Please help me, thanks a lot.
You shouldn't "move" the number, but start the nav-paging call at the current page.
It is done by providing options to the numbers() function (first and last to be specific).
check it here: http://api.cakephp.org/class/paginator-helper#method-PaginatorHelpernumbers

Resources