My very Own paginator
Hello all,
I am using QC for developing since last few months and its fantastic. Sadly, we live in a world where we want to create sites which Search Engines could crawl. While QCubed makes the world come near to perfect with the sweet ways of embedding information in FormState data and making things look neat, it does not help always, not specially when we want to use the QPaginator.
The biggest problem I found with QPaginator was that the 'Previous' and 'Next' links, along with all the page numbers between them are actually rendered as links pointing to the originating page. This is fine for a user but this undoubtedly prevents Google from browsing things on a site which might be available on the pages next to the first page of the pagination; simply because it will never find the link to the next page and since Google is not going to generate events on the page while crawling, all the stuff which is beyond the first page is never indexed.
This destroys a huge amount of hard work which you might have put into developing your own app / site. Considering this, I developed a small control of my own which actually solves this problem. I am using this control successfully with DataRepeater (not tested on Datagrid as yet) and it works great for me. Here is what it would look like:
<< Previous [17 v] [Go] Next >>
That "[17 v]" is actually a QListbox with all the pages and [Go] is the button. Change the page and hit 'go' and it will redirect you to the page you should be wanting to go to. The 'Previous' and 'Next' are clickable (and Google crawlable) links so you know that all your pages are getting indexed by Google.
Note: It uses with the $_GET (uses QApplication::QueryString) and would not work with mod_rewrite. Once again, since I am not using mod_rewrite, I have not tested that but then, that is how it would behave.
I used the Listbox as I thought it was cool. Someone might want to change that.
Once again, if you want to use it anywhere, you cannot be as lousy as with a QDatarepeater or QDatagrid. You need to supply the control with the following:
0. ActionVar -> (I put it as 0th point as it goes into the constructor) This is the GET variable which controls the paging. So if you are using index.php?page=1 for paging to first page then the object shud be created as:
$this->objMyPaginator = new MyPaginator($this, 'page');
If you use index.php?pg=1 for paging then the call shud be something like:
$this->objMyPaginator = new MyPaginator($this, 'pg');
1. BaseFilePath -> This is the file path which is going to be called. Don't push in your query string yet. Usual value should be $_SERVER['PHP_SELF'].
2. QueryString -> This is the field which will get the QueryString. Usual value: $_SERVER['QUERY_STRING']
3. TotalPageCount -> You can calculate that easily I guess.
4. ErrorPageUri -> URI to the error page to where the Paginator will redirect if some stupid values are pushed in through the address bar.
5. CurrentPage -> Page number of the current page. You can set it to 1 for default.
In the data binder, remember to remove the line which sets the 'TotalItemCount' as you are not going to use the QPaginator. Also, the 'LimitClause' will not work (in the data binder) so you can replace that with
QQ::LimitInfo($this->ItemsPerPage, $this->intOffset) and fill in the values for $this->ItemsPerPage and $this->intOffset by using your own logic. Not to forget that those variables should have been declared and filled in with proper values.
I am attaching a zip file with my class and a test page (no data in there, just to show that its linking logic works). Someone who is interested here might want to add in the data arrays and test that.
Note: Please adjust the includes when testing. The default ActionVar is 'page'. Please, please read the code inside to understand more. I cannot really explain all of it.
I hope the team would like to include it into the core for the next release as it solves a MAJOR problem which might occur for sites being developed with QCubed. Also, someone wanting to refine the working of it and remove some useless piece of code is appreciated. I would like to create an example someday. For now, this is it.
Regards,
Vaibhav

Hi Vaibhav,
Great work and looks awesome, I know were I can use it in my own projects. Maybe someone can help you to develop as a pluging or if you want it look this link.
http://qcu.be/content/making-plugging-control
JMI
Yeah. I usually get minimal time to do the extra bit. Even creating the test page was something I did in a hurry. But then, I think this was something I should have had done. Plus, do you think this can be added to the QCubed Core controls? I mean it solves one big issue of everyone who might be thinking to use QC to make his own site!
Regards