Yii Framework Forum: [EXTENSION] AlphaPager - Yii Framework Forum

Jump to content

  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

[EXTENSION] AlphaPager Simple alphanumeric pager Rate Topic: ***** 2 Votes

#1 User is offline   yoshi 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 170
  • Joined: 28-February 09
  • Location:Germany

Posted 29 April 2010 - 02:06 PM

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:
NEW VERSION 1.3 RELEASED
--------------------------------------------------------------
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
1

#2 User is offline   CoLT 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 246
  • Joined: 22-November 09

Posted 01 May 2010 - 12:36 PM

View Postyoshi, on 29 April 2010 - 02:06 PM, said:

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

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

This post has been edited by CoLT: 01 May 2010 - 12:56 PM

0

#3 User is offline   yoshi 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 170
  • Joined: 28-February 09
  • Location:Germany

Posted 03 May 2010 - 05:34 PM

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
0

#4 User is offline   CoLT 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 246
  • Joined: 22-November 09

Posted 04 May 2010 - 08:29 AM

View Postyoshi, on 03 May 2010 - 05:34 PM, said:

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 ;-)
0

#5 User is offline   CoLT 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 246
  • Joined: 22-November 09

Posted 06 May 2010 - 08:22 AM

Any news?:)

Would be nice to use it ;)

Well done extension

CoLT
0

#6 User is offline   CoLT 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 246
  • Joined: 22-November 09

Posted 09 May 2010 - 06:05 PM

Any further with it? :)
0

#7 User is offline   yoshi 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 170
  • Joined: 28-February 09
  • Location:Germany

Posted 11 May 2010 - 07:32 AM

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
0

#8 User is offline   CoLT 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 246
  • Joined: 22-November 09

Posted 11 May 2010 - 08:23 AM

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

This post has been edited by CoLT: 11 May 2010 - 10:50 AM

0

#9 User is offline   yoshi 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 170
  • Joined: 28-February 09
  • Location:Germany

Posted 12 May 2010 - 03:02 PM

View PostCoLT, on 11 May 2010 - 08:23 AM, said:

I can't find how to add above mentioned alphabet :) I understand now it supports
ąčęėįšųūž ?


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.

View PostCoLT, on 11 May 2010 - 08:23 AM, said:

Btw, have you got simple way to add AlphaPager to Gii CRUD?
Or do we have to get back to old methods?


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

Regards
0

#10 User is offline   CoLT 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 246
  • Joined: 22-November 09

Posted 12 May 2010 - 03:40 PM

View Postyoshi, on 12 May 2010 - 03:02 PM, said:

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

This post has been edited by CoLT: 12 May 2010 - 03:49 PM

0

#11 User is offline   yoshi 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 170
  • Joined: 28-February 09
  • Location:Germany

Posted 13 May 2010 - 07:36 AM

View PostCoLT, on 12 May 2010 - 03:40 PM, said:

By the way, letter should be case insensitive when searching


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
WHERE (searchcol LIKE 'a%' OR searchcol LIKE 'A%')
....

Some other/better suggestions for this?

Regards
0

#12 User is offline   CoLT 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 246
  • Joined: 22-November 09

Posted 13 May 2010 - 05:20 PM

View Postyoshi, on 13 May 2010 - 07:36 AM, said:

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
WHERE (searchcol LIKE 'a%' OR searchcol LIKE 'A%')
....

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.yiiframew...CListView#c1219

Thanks!
CoLT

This post has been edited by CoLT: 13 May 2010 - 06:03 PM

0

#13 User is offline   yoshi 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 170
  • Joined: 28-February 09
  • Location:Germany

Posted 14 May 2010 - 04:06 AM

View PostCoLT, on 13 May 2010 - 05:20 PM, said:

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 :)


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.

View PostCoLT, on 13 May 2010 - 05:20 PM, said:

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


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
0

#14 User is offline   CoLT 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 246
  • Joined: 22-November 09

Posted 14 May 2010 - 07:03 AM

View Postyoshi, on 14 May 2010 - 04:06 AM, said:

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
0

#15 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 14 May 2010 - 09:17 AM

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...ensitivity.html
0

#16 User is offline   CoLT 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 246
  • Joined: 22-November 09

Posted 14 May 2010 - 12:20 PM

View PostMike, on 14 May 2010 - 09:17 AM, said:

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...ensitivity.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 :)

This post has been edited by CoLT: 14 May 2010 - 12:30 PM

0

#17 User is offline   yoshi 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 170
  • Joined: 28-February 09
  • Location:Germany

Posted 14 May 2010 - 03:58 PM

View PostCoLT, on 14 May 2010 - 12:20 PM, said:

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
0

#18 User is offline   CoLT 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 246
  • Joined: 22-November 09

Posted 14 May 2010 - 05:40 PM

View Postyoshi, on 14 May 2010 - 03:58 PM, said:

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
0

#19 User is offline   yoshi 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 170
  • Joined: 28-February 09
  • Location:Germany

Posted 14 May 2010 - 05:58 PM

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
0

#20 User is offline   CoLT 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 246
  • Joined: 22-November 09

Posted 15 May 2010 - 01:51 AM

View Postyoshi, on 14 May 2010 - 05:58 PM, said:

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
0

Share this topic:


  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users