Hi i am facing a issue with the pagination helper. I am sorting the records based on user criteria like date range etc via drop downs . And it works fine. It paginates properly. But when i click on page 2, it shows page 2 of all results an not the sorted results. How can i fix it. The fields are sorted via POST and not GET and don't want it to be GET
You can try to store the post in the session, and then to fetch it when the page is loaded.
i.e.
if(isset($this->data)){
if(isset($this->data['clear'])){ //some field (button) which will clear the session
$this->Session->delete('post');
unset($this->data);
}
$this->Session->write('post', $this->data);
}
if($this->Session->read('post')){
$this->data = $this->Session->read('post');
}
If you want take a look on this component: Filter component. The post is a little bit old, but the component is adequate still and I am using it in my projects :)
It's hard to reverse engineering your source from a screenshot but i think the main problem is you're using POST therefore when user clicks to '2' you need to use some javascript to mimick a POST request.
Related
So I'm using laravel 5.1 and I'm stuck in a weird situation.
I have 2 models Seasonand Tournament and lets say the url to add a Season model is ..../seasons/add and to view the season would be ..../seasons/(id)... standard stuff right?
But now I want to add a tournament from the link ..../seasons/1 and so I click a link that takes me to ..../tournaments/add... how can I send the Season model to that page without submitting a form with hidden input?
Currently I have this setup ..../seasons/1/tournaments/add using blade to generate the links. But this method just doesn't feel right....
Thanks.
How can I send data from one page to another using Laravel?: I would suggest that you do this from your controller. Take a look at Redirecting With Flashed Session Data, it might come in handy.
From the Flash Data documentation: "[...] it will only be available during the subsequent HTTP request, and then will be deleted [...]"
You can send your model, static values or whatever you want using ->with:
redirect('route')->with('key', 'value');
I have this scenario that I need to keep the current pagination and search filter on my employee list after I have added or updated an employee record. Since I am using GET method for pagination and search filter, I am planning to keep the URL after add/update action so that the user will be redirected to the employee list with current search filter and page number.
My question now is should I keep this URL in Session or better store it in a table? The URL will be removed once the user go to other modules (e.g. department, subject, etc).
I am using Laravel 4, maybe they have a function that I can use for this kind of scenario?
Flashing it to the session would probably be the easiest way to do this.
Session::flash('key', 'value');
I’m hoping this is a simple fix for someone better versed in customizing Magento…
I have a custom search form (on home.phtml) and results page (cms loading customresults.phtml) which returns a filtered collection of products, based on POST data entered in the form.
The process:
Form > POST values > multiple calculations based on POST > MySQL (core_read) query based on calculation results > product ID array (referred to below as $wow) based on query
Then:
$collection = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*')->addAttributeToFilter('entity_id', array('in'=>$wow))
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection)
$magento_block = Mage::getSingleton('core/layout');
$productsHtml = $magento_block->createBlock('catalog/product_list');
$productsHtml ->setTemplate('catalog/product/list.phtml')->setCollection($collection);
echo $productsHtml ->toHTML();
Results page loads nicely with the correct products showing. Toolbar loads and looks normal.
THE PROBLEM: on changing any setting in the toolbar on the results page, the page reloads and we’re left with no search results.
I assume the reload is killing the POST values…
Is there a way to (A) circumvent the page reload for toolbar functionality? Or alternatively, is it possible to somehow (B) retain the posted data or (C) force data re-submission on reload?
Any tips would be sincerely appreciated.
Solved the problem by using GET method instead of POST.
Not the solution I wanted, but it’s an easy workaround.
Just in case anyone else out there is having a similar issue.
I just finished products website.There is a search form in the website.
Search result are working fine.when I click on the result item that retrieving based on ID on the next page.
The problem is that When click back I need to search same keyword to get the result list. Is there any solution to show results on that page
You can use sessions ( http://php.net/manual/en/ref.session.php ). There are 2 ways to do it.
Have in your session your search results. So for example will be something like this:
$_SESSION['destination'] = $_POST['destination'];
$_SESSION['ID'] = $_POST['result_id'];
You can have to your session only the ID and then in this id to have your data serialized ( http://php.net/manual/en/function.serialize.php ) . The when you want to export your search again you simply unserialize ( http://php.net/manual/en/function.unserialize.php ). So it will be:
$_SESSION[$my_id] = serialize($_POST);
and to get the data
$data = unserialize($_SESSION[$my_id]);
The most compatible is to use the search term as an $_GET-variable.
Have your search form do a GET instead of a POST, that way what was searched for is retained by the browser.
I'm not sure at what level you are at, but have you thought about caching? You can use Memcaching which would allow you to cache the previous page.
You could also change your query from a POST to a GET like mlaw just mentioned.
You can even use Sessions to keep the results valid. Sessions can be found here
Conceivably, you could save the POST of the search to a variable, pass it forward when you click on the product, then, if you click a link that takes you back, send that information as a new POST. Still wouldn't affect the browser's back button usage, but if you're looking for a programmatic answer, there's one.
I am not sure the correct terminology for the process that I am trying to describe. I don't even know which platform is underlying the technique. If you understand my description, please give the link to the site(s) and or the keyword name of the process. I think it is done by AJAX, but I am not certain. I use php as the backend code, I just need to find a way to dynamically display the results. Please give suggestions. I forgot the name of the sites that use this, and my link history expired.
TIA
Description:
The page would have a search form and options. After the user submits, the search is initiated, and the results appear inside the dedicated result area. The page does not refresh, just the info inside the result area.
The display area will show 20 (or whatever) results (lines). There will be next, and previous buttons. If you hit next, the next set of results will display.
I am writing a code that generates 20 results for each display. There is no set number of results, so the results might have a start/first page, but do not have an end page.
Each time the user hits 'next', the program would generate/load new results. It would also store previous results, so that when a user hits 'prev', the previous results can instantly come up.
What techniques/program are theses?
Having recently handled pagination with Code Igniter (php framework), the following links might help you and anyone else out:
http://tympanus.net/jPaginate/
http://codeigniter.com/forums/viewthread/93045/
Usability is important and AJAX pagination introduces some important questions that need addressing regarding pagination, the following article will give some usability guidelines for displaying results in a table:
http://thedesignvanguard.com/crud-r-for-read
Code Igniter Prototype Framework Ajax Pagination:
http://codeigniter.com/wiki/AJAX_Pagination_with_CI_Pagination_Library/
Since we're using jQuery, we chose the following, Codeigniter jQuery framework for AJAX pagination
http://tohin.wordpress.com/2008/08/12/codeigniter-ajax-pagination/
http://tohin.wordpress.com/2008/10/07/codeigniter-ajax-pagination-exampleguideline/
It is not AJAX for sure.
Nobody uses AJAX for the pagination.
And there are about zillion pagination examples over internet
The only thing is never described in articles is how to persist search options for the other pages.
But it's simple enough: http_build_query() can help you
You need to have a GET/POST form submitted via AJAX which contains the fields in the search term and page number.
If you are going to set the page size to 20 results, page_num=4 will show results from 61-80 results.
Usually search results are GET instead of POST (Ex: See Google search results ) along with the page_number as another attribute and value.
#IVAN .. good to know that the library came helpful..
About that searching option; check the recent commit in github
http://github.com/neotohin/CodeIgniter-Ajax-pagination-Library there is an additional parameter added for searching.
I think the simple code in readme is enough for understanding the mechanism.
You could use datatables
https://datatables.net/
https://datatables.net/examples/data_sources/server_side.html
With this plugin using jquery also you could use server sided page request , you just have to handle the plugin post using Ajax.
post automatically sends row , page offset column, search criteria you just have to provide the json encode return
and the plugin automatically has library in featuring pagination, search sort number of rows per page and the table formatting.
Needed are jquery, and the plugin css and js for this to work
let me know if you understood my explanation.
thanks (=