Why is my custom paginator not loading results as it should? - laravel

In my last post I was asking how to let the user decide on pagination numbers. I thought I had figured it out, but now it appears I messed something up, as the pagination seems to work but as soon as you go to the next page, it's blank and the number of pages is set to 1.
importeren.blade.php page (this is where the data of the imported file(s) is shown). This also has the pagination links for Laravel, I feel the error could be within there but I am not 100% sure.
DataController index method that loads the amount of pages as specified by the user:
Here is a short clip displaying what happens once I enter the results for the amount of records to be displayed per page.
I do not know what I am missing, but if anyone could help out that'd be amazing.

You should append your parameter to each pagination link.
To do so you can use {{$datas->appends(['paginate_number' => request('paginate_number')])->links()}}
I will suggest to change method="POST" to method="GET" in the form.

First try as a static like this
$datas = Data::paginate(10);
If it works then you have to change $request->input('paginate_number')

Related

How to load a specific number of records per page and add an more button

On my page I would like to output all records of a specific folder
but the number should initially be limited to a certain quantity (to reduce the loading times). With a "Load more" button further records should be loaded.
Does anyone have a hint on how I can achieve this?
I have already found several approaches on the web in connection with AJAX, but since I'm not familiar with this yet, more questions than answers have emerged ...
For info: I use an own Template Extension / Distribution under Typo3 9.5.8
Thank you in advance for any help!!
The state of the art solution is the AJAX solution, where you load only the required records from the server and modify the page on the fly.
Another option would be an URL parameter which is evaluated by your extension.
With the parameter the full list is shown,
without only the first N and a button with the link to the same URL including the parameter for the full list.
Make sure the paramter is handled correctly and generates another cached version of the page. (keywords: cHash)
As you now have two pages with partially identical content: don't forget to tell the searchengines that the short variant should not be indexed.
You could use the Paginate Widget like documented here: https://docs.typo3.org/other/typo3/view-helper-reference/9.5/en-us/typo3/fluid/latest/Widget/Paginate.html
By overriding the paginate template file and only rendering the pagination.nextPage link, you could load the nextpage via AJAX.

Long polling in Django - can't get page to update

I'm new to Django so apologies if this is a really stupid question but I'm trying to get a table to reload database values and when I open the page in a browser it loads ok initially but when it tries to reload nothing appears to happen. When I look in the network section of inspect element I can see repeated 404 page not found errors. I've been searching stack exchange etc. for a few days and I've tried various types of quotes etc. round the url tag but no joy. I'd really appreciate any help anyone can give me on this. I'm using python 3 and django2.
Project level urls.py
project level urls
App Level urls.py
App level urls
App views
App views
HTML
html
Directory Structure
directory structure
Terminal
enter image description here
Thanks in advance
The problem is a simple typo: you have a space between the { and the % in your url tag. This is causing Django to not recognise it as a tag, so the Ajax is using the literal string "{ % url ... }" as the URL which explains the mess you see in the terminal. Remove the space.
(Note, you still might not get the result you expect, since your Ajax function returns a complete HTML page but you are inserting that result inside a div in an existing page; you probably either want to replace the whole page or return a template fragment from your view.)

How do I display a barcode, only when it is in the last page

I have a document, in which there is a page, that flows. I don't know till how many pages the table is going to flow. Now, I need a barcode to be displayed in the last page (last flow page). I tried writing the rules, by using
SYS_Page_PrintedValue = SYS_Page_TotalPrinted,
also tried SYS_PageInDocument = SYS_PageTotalInDocument
and then I have tried SYS_Page_PhysicalInDocument = SYS_PageTotalPhysicalInDocument.
But did not work. Can anyone help me with this?
Thanks in advance.
By placing the Barcode relative to the bottom of your table, as the table flows it will therefore always be on the last page.
You can place barcode directly on the flow page under the flow frame and set that page as last flow page.

magento catalogsearch search for all products (like a view all brands page )

For a project I need to make a kind of view all manufactures page, I am hoping to use catalogsearch but without any parameters. What I mean is the normal catalogsearch is ran and all shoes in all manufacture categories are returned.
The url that is normally passed is testshop.com//catalogsearch/result/index/?manufacturer=2522&q=shoe%20manufactures this works but when I try to pass testshop.com//catalogsearch/result/index/? (or along those lines) this does not work.
I have not started coding this yet as I am not sure where to begin so need a point in the right direction.
I am thinking of just finding the default category id and using this, but not sure if this is the best option to use.
Any advice or help will be great as always. Will post my finished code on here once complete as I think with magento help can be a bit limited.
Cheers
Jason
Maybe try getting the search Model pragmatically
Here is the code to get the Search model:
$search = Mage::getSingleton('catalogsearch/advanced');
To actually search put in the following:
$search = Mage::getSingleton('catalogsearch/advanced')->addFilters(array('name' => $term));
Then to get the results in an object, enter the following line:
$search->getProductCollection();
Hope this helps
I did it. It was a bit of a hack but works perfectly.
I noticed that if you make a search and remove all the filters you are left with a GET request that look something like this /catalogsearch/result/index/?q=Shoe+Brand . But the filters where not showing on the left hand side as a normal catalogsearch would.
So I found the default category id and added this to the GET request. The GET request now looked like this /catalogsearch/result/index/?cat=2&q=Shoe+Brand .
Although the GET request included q=Shoe+Brand it was not actually using this as search criteria.
This was now returning a catalogsearch page with the default category as a filter.
This was showing default category in the filter and breadcrumbs so I had to change the appropriate phtml files to check for this and display 'all brands' instead of 'default category'.
Hope this helps someone else
Jason

Paginating a long list of checkboxes in Magento

it would be awesome if someone could help me with this - I've already spent more than a day on it. :(
In a phtml file in Magento, I'm displaying a long list of products with a checkbox next to each. I've already added some code to paginate this list. The problem is, when I move to say page 2, I need to 'remember' which boxes were selected in page 1, and select them when I move back to page 1. I know how to use javascript to detect if a checkbox is checked or not. I was planning to save an array of selected boxes in the magento session - adding to it when more boxes are checked and deleting when boxes are unchecked. But my session-changing code is PHP, and my checkbox-detector is javascript. I know I can't call my session-changing function from javascript - I've been told that I would need AJAX to do this. I don't know any AJAX at all. Is there any other way to do this?
I'd be happy to post relevant snippets of my code if anyone can help me. Thanks!
UPDATE:
Okay, so I decided to use AJAX after all, and I've added a lot of AJAX code already. The problem is, it's not working. Btw, I'm not using jQuery. When I write this in Magento:
xmlhttp.open("POST", 'adjust_session.php', true); xmlhttp.send(params);
exactly where do I need to put my adjust_session.php file? It's not working if I put it in the same folder as my phtml file (where I'm calling the open function).
Thanks!
How are you actually doing the pagination? If you have to make a round-trip to the server for the paginated data anyway, send a list of checked/unchecked with it and toggle in the session. Then, when rendering the new page, either check the boxes in the HTML directly, or just pass a list of currently checked boxes in as JS and parse it on the response.
Alternatively, if you are doing everything on one page (and using AJAX for pagination already), you could also hold onto an array in JS and recheck the boxes after you render them.
Hope that helps!
Thanks,
Joe

Resources