Pagination

Permalink
I am going to have a search box and then will do a sql query against my database. I would like to be able to show the results, one record at a time, sort of looking almost like a website, with pagination. Think of it as searching for home listings, and then showing the listings one at a time, pretty much full page with pagination and all the info for that home listing.

I could possible use Data Display??? Would that make it easier, or better?

Has someone done this already? Is there any examples of something close?

 
ronyDdeveloper replied on at Permalink Reply
ronyDdeveloper
Not sure about any add-on. But if you want to display 1 record each page with pagination, simply create a model and put
protected $itemsPerPage = 1;


If you are not sure how to write a model page, just follow the below code:
<?php  
defined('C5_EXECUTE') or die(_("Access Denied."));
Loader::block('library_file');
Loader::library('item_list');
class ModelName extends DatabaseItemList{
   protected $autoSortColumns = array('column name');
   protected $itemsPerPage = 1; 
   public $_table = 'DatabaseTableName';
   protected $queryStringPagingVariable = 'page';
   function __construct(){
   $this->setQuery('SELECT * FROM TableName');
   }
}
?>


Hope this helps!

Rony
enlil replied on at Permalink Reply
enlil
A good starting point to achieve something like this might be to download the free Page List Teasers addon. Then create each "home listing" as a separate page. Use a page list with the teasers template applied to pull the "Main" area from each "home listing" page into the page list. You can then choose to display the page list one "page" at a time. Clicking the link would then bring your users to each individual "home listing" page...

EDIT: I apologize my mind wandered as I replied, and I quickly forgot about the "search" part :)

Page List+ by skybluesofa can be used as a search block as well as all of it's other wonderful out of the box "page list" features.

The page list teasers approach for page lists can be achieved by simply copying the teaser templates into the page list+ package. See this how-to for instructions how to do so:

http://www.concrete5.org/documentation/how-tos/designers/magic-data...
asawyer13 replied on at Permalink Reply
I will have too many listings to create a page per listing like I think you're suggesting, but I have a few ideas to try, and since I'm so new to C5, I have a lot to learn.

I have a second question related to this, so I thought I would ask here if that's okay?? Once I get the listings being shown, I'd like to do 2 things. I would like to insert a record into a log table for all the records that could be retrieved, so for example, if someone searched for listings in Phoenix, and there were 258, I would like to insert into a log 258 records so I could track which ones were searched for. In addition, I'd like to actually indicate in the log record if the listing was actually shown on the screen.
What would be the correct way to do this in C5?

For now, I'm not knowledgeable enough to understand everything yet, but if I understand what the best practices for C5 would be, it will help me when I really get into it.