[EXTENSION] AlphaPager

Hi,

this is the discussion topic for the AlphaPager extension.

Short description:

This extension is an alphanumeric pager consisting of a paginationcomponent and a widget for a linkpager. It’s mainly a modification ofyiis CPagination and CLinkPager classes to achieve a pager which adds aCONDITION to a CDbCriteria instead of LIMIT/OFFSET like the standardpagination does.Therefore it’s possible to page through data (like an addresslist)by selecting a letter (A-Z) for a specified attribute to start with(e.g. the last name).

In addition it’s possible to control a standard pagination as kind of subpagination per letter.

The download and some documentation could be found inside the extension repository: AlphaPager

Edit 2010-11-14:

[size="4"]NEW VERSION 1.3 RELEASED[/size]


With everything needed to include AlphaPager with Grid-/ListView (including AJAX support). ActiveDataProvider, ArrayDataProvider and extended versions of GridView and ListView.

These are reworked versions of those already published within this topic.

Take care when updating from a previous version of Ap, because as mentioned by samdark i’ve updated the file- and classnames to avoid potential naming-conflicts. See README.txt from the package!


If you have any feedback, suggestions or problems you’re welcome to comment! :)

Best regards

Nice extension ! ;)

Maybe considering localization?:)

For example I need to use the following ABC:


Aa Ąą Bb Cc Čč Dd Ee Ęę Ėė Ff Gg Hh Ii Įį Yy Jj Kk Ll Mm Nn Oo Pp Rr Ss Šš Tt Uu Ųų Ūū Vv Zz Žž.

And of course when I set the last letter to ž strange things comes out :D

Greetings,

CoLT

Hi Colt,

you’re absolutly right. I didn’t add this because i don’t need a different alphabet. ??? But as i released it as an extension it definitely should support this!

Beside the great idea of aztech (he mentioned in his extension review) i’m planning to add localization to this extension. I think i’ll add the alphabets from CLDR. Hopefully i’ll get some free time tomorrow :D

Best regards

oKey, thanks! waiting for news to test out :wink:

Any news?:)

Would be nice to use it ;)

Well done extension

CoLT

Any further with it? :)

Hi,

sorry i hadn’t much time to spend.

But now the new version 1.1 is online! :)

Unfortunately i couldn’t find a satisfying way to use CLDR data the way i wanted to.

Because even the index alphabets are different for some languages (more or less characters) and therefore i couldn’t map them in a correct way to the db character set.

But nevertheless now there are 3 defineable character sets. Use charSet to define the alphabet you want to show as pager buttons. Second is activeCharSet that defines which buttons are enabled. And third is a dbCharSet where you could set the equivalent characters for the db query condition. The last isn’t needed in most cases but maybe you would like to have a button ‘Ę’ but inside your db you’re having english data, so you can map ‘Ę’ to show up as ‘E’ in your query.

Take a look into documention for some examples.

I’ve also added a numeric-button (numeric button in an alphanumeric pager is kind of weird - i know :D) but it could be useful if you have only a few entries starting with a digit. Like showing band names you’ll have a few bands e.g. ‘5 finger death punch’ starting with a digit, but not enough to add a hole pager for 0 to 9.

Let me know if any of you have further suggestions, found any bugs etc.

Best regards

Great! ;))

I’ll start checking it out right now ! ;)

Btw, have you got simple way to add AlphaPager to Gii CRUD?

Or do we have to get back to old methods?

I can’t find how to add above mentioned alphabet :) I understand now it supports

ąčęėįšųūž ?

Thanks!

CoLT

Hi,

you must set charSet array to match the needed alphabet.

E.g.:




$alphaPages->charSet = array(Ą,Č,D,Ę,Ė,F,G,H,Į,Y,J,K,L,M,N,O,P,R,Š,T,Ų,Ū,V,Ž);



This will show up a button for each of these characters. By default it’s the latin alphabet A-Z.

I have to check that. Didn’t try it up to now, cause atm i’m only working/tuning on existing projects.

Regards

Worderful it’s just what I18N needs! ;)

Could you take a look to Gii Crud with alpha pager? Would be VERY useful to comply with it, Gii now is stable.

[edit]

Here is full Lithuanian alphabet to use:


$alphaPages->charSet = array('A', 'Ą', 'B', 'C', 'Č', 'D', 'E', 'Ę', 'Ė', 'F', 'G', 'H', 'I', 'Į', 'Y', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'Š', 'T', 'U', 'Ų', 'Ū', 'V', 'Z', 'Ž');

By the way, letter should be case insensitive when searching

Thanks again!

CoLT

Hi,

unfortunately this depends on your dbms. While MySQL and MS-SQL always do a case insensitive search on non-binary data, most of the others don’t do so. In PostgreSQL you have the ILIKE operator and with Oracle and DB2 you need to LOWER the search column and use a lowercase character for searching. :(

Maybe it’s an idea to add an optional double-condition like [sql]WHERE (searchcol LIKE ‘a%’ OR searchcol LIKE ‘A%’)[/sql]…

Some other/better suggestions for this?

Regards

Hello,

I’m using MySQL 5, and Clients with e.g. ‘Z’ or ‘z’ are case sensitive (letter button does not highlight on lower case). Where and how should I implement double condition?:) it would be very useful to extension and other DBMS too :)

Could take a look at Gii Crud and how to implement your extension in right way?

[edit]

Custom view template, maybe this could help a bit? http://www.yiiframework.com/doc/api/CListView#c1219

Thanks!

CoLT

Hi Colt,

oh, i think i understood you wrong. You would like to use case sensitive buttons, right?

The extension doesn’t affect the letter case. You can set the alphabet containing upper and lower case letters:


$alphaPages->charSet = array('A','a','Ą','ą', 'B','b','C','c',....);

But as mentioned before the search on a MySql db would be case-insensitive anyway…

I’ll have a look at that this weekend.

As a quick fix for now (only MySQL) you can replace line 129 in AlphaPagination.php


$criteria->addSearchCondition($this->attribute,$search.'%',false);

with


$criteria->addSearchCondition($this->attribute,$search.'%',false,'AND','LIKE BINARY');

This will make search on MySQL case sensitive.

I took a quick look at Gii. Beside that this is a pretty cool tool, afaik you would just need to create a custom template for the controller and the admin-view (or whatever)?! But to be honest i can’t see the need for this.

In contrast to a standard pager you would not want to have an alphapager on each e.g. admin view, would you? And for example the db column alphapager should use couldn’t be determined automatically.

Regards

Hey,

Thanks for quick reply! You understood me right in the first post, somehow alphapager does case - sensitive search on MySQL(@Wamp, Win) and I need case - insensitive as it should properly be :)

As for Gii Crud admin view - there is no necessity BUT in the Index (previous List) View it would quite very good to see such a user friendly sorting pager! :) It should be added to default Yii CListView!

:) Waiting for your opinion/solution here :)

Thanks!

CoLT

I think you need to check the COLLATION of your MySQL tables to change case sensitivity behavoir. Check for ‘_ci’ (case insensitive) and ‘_cs’ (case sensitive) suffix.

More details here:

http://dev.mysql.com/doc/refman/5.0/en/case-sensitivity.html

Great idea, double checked utf8_lithuanian_ci I doubt it would be a language issue.

[edit]

Tested on PhpMyAdmin:

SELECT *

FROM client

WHERE ClLName LIKE ‘ž%’

LIMIT 0 , 30

It returns case insensitive results. Strange behaviour when lower case is set Alphapager button is not highlighted :)

Hi,

this IS strange - can’t reproduce it. Actually alphapager doesn’t care about the characters, it’s serially numbering the charSet alphabet and uses these numbers to determine the selected button.

The only thing i could think of is that you have defined a different activeCharSet?

The comparision between charSet and activeCharSet is case sensitive. Is the ‘lower case’-button always hidden (has css class ‘hidden’ and is by default gray)? These buttons could be clicked but are never ‘selected’.

Regards

Hey,

I have only added charSet


$alphaPages->charSet = array('A', 'Ą', 'B', 'C', 'Č', 'D', 'E', 'Ę', 'Ė', 'F', 'G', 'H', 'I', 'Į', 'Y', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'Š', 'T', 'U', 'Ų', 'Ū', 'V', 'Z', 'Ž');

Still testing it, and would like to integrate with Gii Crud’s CListView if possible. It would be very easy to pick eg. customers with picked surname letter. :) Any ideas?

CoLT

Salut,

first of all i’ve uploaded a new version (1.2) to the extension repository (i’ll update the docu tomorrow - i think ^^).

  1. To avoid the case problems i’ve added a flag forceCaseInsensitive to AlphaPagination. Set to true this will make cross charset comparison case-insensitive and also uses the LOWER-function to make the sql condition case-insensitive (afaik most dbs support this function).

  2. Added a flag to completly hide the ‘SHOW ALL’-button.

  3. Added the ListPager (AlphaListPager).

AND i’ll take a look at Gii integration - i swear ;)

Regards

Very good news! ;) I’ll check it out and post reply.

Would be very good to integrate it with with Gii CListView, both are very useful:

You get the sorting option, selected/total records default count AND AlphaPager would bring even more user friendly select view! :)

Thanks!

CoLT