Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

New plugin: SmartyColumnSort!
Goto page Previous  1, 2, 3, 4, 5, 6  Next
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins
View previous topic :: View next topic  

How useful is SmartyColumnSort?
Not at all
6%
 6%  [ 1 ]
It's ok
6%
 6%  [ 1 ]
Quite useful!
13%
 13%  [ 2 ]
Most useful!!
73%
 73%  [ 11 ]
Total Votes : 15

Author Message
TGKnIght
Smarty Junkie


Joined: 07 Sep 2005
Posts: 580
Location: Philadelphia, PA

PostPosted: Wed Nov 02, 2005 3:58 pm    Post subject: Reply with quote

The patch works well on this end. I think the graphical arrow idea is a good one, I guess either passing in the image path in the application or the template level would work.

I am currently just using a style to highlight which header is sorted on, but having the arrow would make it much cooler looking =)

By the way I took your idea to remove the extra & for use with my paginate script. Smile
Back to top
View user's profile Send private message Visit poster's website
TGKnIght
Smarty Junkie


Joined: 07 Sep 2005
Posts: 580
Location: Philadelphia, PA

PostPosted: Wed Nov 02, 2005 9:47 pm    Post subject: Reply with quote

By the way, I came up with something that might be of interest to anyone using this... I didn't want to have to set the default every time I used this class, so what I did was setup the default to automatically be the first column in ascending order, unless you overwrite it.

I know I probably should be extending your class, but I am lazy and somewhat new to OOP so I modded your class directly.

Anyway, just a quick change in the constructor at line 57 from :

Code:
if($column_array) $this->setColumns($column_array);


to :

Code:
      if($column_array) {
         $this->setColumns($column_array);
         $this->setDefault($column_array[0], 'asc');
      }
Back to top
View user's profile Send private message Visit poster's website
Vaccafoeda
Smarty n00b


Joined: 01 Nov 2005
Posts: 3

PostPosted: Fri Nov 04, 2005 4:40 am    Post subject: Reply with quote

XHTML Compliance Patch:

Add
Code:
$ampersandLocation = strpos($url,'&');
if ($ampersandLocation!==false) {
  $url = str_replace('&','&',$url);
}

above the lines:
Code:
$class = $selected && $selected_class ? "class=\"$selected_class\" " : '';
return "<a {$class}href=\"$url\">$html</a>";

in function.columnsort.php
Back to top
View user's profile Send private message
gazoot
Smarty Regular


Joined: 20 Feb 2005
Posts: 35

PostPosted: Sun Nov 06, 2005 6:28 pm    Post subject: Reply with quote

Vaccafoeda, thank you, nice find. I'll update it shortly.


/Gazoot
Back to top
View user's profile Send private message
talo
Smarty Rookie


Joined: 18 Oct 2005
Posts: 16

PostPosted: Mon Nov 14, 2005 9:43 am    Post subject: Columnsort + Pagination Reply with quote

Hi,

I was wandering if any of you guys have successfully merged Columnsort and Pagination?

If you have please please can i have it?

I've got this one pagination plugin for Smarty and it works excellent then i combined it with html_table function of smarty and got that to work as well, now im trying to add the column sort in there.

I managed to get the column heading's links with the right values but when click on it doesnt actually do anything.

and i cant seem to get it right.

help.......

Tnx,
T.
Back to top
View user's profile Send private message
talo
Smarty Rookie


Joined: 18 Oct 2005
Posts: 16

PostPosted: Mon Nov 14, 2005 12:28 pm    Post subject: never mind Reply with quote

Hi,

no worries, i got it!!!

Tnx anyways,
T.
Back to top
View user's profile Send private message
jchum
Smarty n00b


Joined: 16 Dec 2005
Posts: 1

PostPosted: Fri Dec 16, 2005 3:29 pm    Post subject: Reply with quote

I've made one small modification to the SmartyColumnSort.class.php. Apparently, it doesn't play nicely with arrays in GET. In my case, my table is a search result generated from a form in which the end user may choose what filters to apply on the search by checkboxes.

Original:

Code:
if($key != $this->_column_var && $key != $this->_sort_var)
         { 

               $nexturl .= $key.'='.$value.'&';

         } 


Revised:

Code:
if($key != $this->_column_var && $key != $this->_sort_var)
         { 
            if (is_array($value))
            {
               foreach($value AS $v)
               {
                  $nexturl .= $key.'[]='.$v.'&';
               }
            } else {
               $nexturl .= $key.'='.$value.'&';
            }
         } 


Regards,
Jonathan Chum

--
http://www.primoplace.com
Home of the Hotmail, Gmail, Yahoo Address Book Export Library
Back to top
View user's profile Send private message
TGKnIght
Smarty Junkie


Joined: 07 Sep 2005
Posts: 580
Location: Philadelphia, PA

PostPosted: Fri Dec 16, 2005 4:40 pm    Post subject: Reply with quote

Gazoot, was wondering if you had followed up with that icon indicating the direction of the sort... If not I might try to tackle it before years end.
Back to top
View user's profile Send private message Visit poster's website
gazoot
Smarty Regular


Joined: 20 Feb 2005
Posts: 35

PostPosted: Sat Dec 17, 2005 10:31 am    Post subject: Reply with quote

Hi guys! Thanks for the GET array patch, jchum. I must look through some other projects to see if I missed that anywhere. The latest version is now uploaded to http://hem.passagen.se/gazoot/scs/smartycolumnsort.zip , I didn't tested it, but I'm quite certain it will work.

TGKnIght, I'll try to do the arrow feature tonight, if I cannot find the time I'll post again so you can try if you want. Thanks for your help!


/Gazoot
Back to top
View user's profile Send private message
gazoot
Smarty Regular


Joined: 20 Feb 2005
Posts: 35

PostPosted: Sat Dec 17, 2005 6:33 pm    Post subject: Sort image update finished Reply with quote

Yo! Back with a new version that indicates what direction the sort is going, ascending or descending. To use it, just add two tags to the first columnsort tag:

Code:
{columnsort selected_class="selected" html="name" asc_image="/images/arrow_up.gif" desc_image="/images/arrow_down.gif"}


Should be quite easy to implement. Smile I hope this is what you want, TGKnIght. Let me know how to improve this feature!

Download URL: http://hem.passagen.se/gazoot/scs/smartycolumnsort.zip

/Gazoot
Back to top
View user's profile Send private message
DJ_SPHYX
Smarty Rookie


Joined: 23 Dec 2005
Posts: 12

PostPosted: Tue Dec 27, 2005 11:27 am    Post subject: Reply with quote

HI there, call me stupid but I don't really see what this addon is doing?
Could you explain it to me please?

DJ_SPHYX
Back to top
View user's profile Send private message
gazoot
Smarty Regular


Joined: 20 Feb 2005
Posts: 35

PostPosted: Tue Dec 27, 2005 1:52 pm    Post subject: Reply with quote

Hi, sorry about me not explaining how it works. It is a html table column sorter. If you have a table with 3 columns, lets say name and email and country, this plugin will automatically make the header columns clickable, and sort the table depending on what you click.

I found a live example of it here:
http://www.kryogenix.org/code/browser/sorttable/

That example is dynamic and very cool for simple tables, but for more complex and bigger tables (especially when you have subheaders with different colspans), it sometimes doesn't work very well. But it illustrates how SmartyColumnSort works. And SmartyColumnSort will always work on every browser, since it is server-side. But for simple tables, I would try the kryogenix solution. Easier to implement, and DHTML is always nice. Smile


/Gazoot
Back to top
View user's profile Send private message
DJ_SPHYX
Smarty Rookie


Joined: 23 Dec 2005
Posts: 12

PostPosted: Tue Dec 27, 2005 1:59 pm    Post subject: Reply with quote

Wow thats nice!
I'll implement it into my project since it is allways cool to decide how something is displayed, for example personal messages and so on..

Thankyou for this addon Wink


EDIT: maybe you could help me out here: http://www.phpinsider.com/smarty-forum/viewtopic.php?p=26860#26860 ?
Back to top
View user's profile Send private message
gazoot
Smarty Regular


Joined: 20 Feb 2005
Posts: 35

PostPosted: Tue Dec 27, 2005 2:52 pm    Post subject: Reply with quote

Glad you liked the addon! I replied to your post as well, hope you find my answer useful too.


/Gazoot
Back to top
View user's profile Send private message
TGKnIght
Smarty Junkie


Joined: 07 Sep 2005
Posts: 580
Location: Philadelphia, PA

PostPosted: Tue Dec 27, 2005 6:29 pm    Post subject: Reply with quote

Awesome, the graphical thingy is perfect Smile

Something went wrong once you added that array in URL thing.

Revert these lines to append an actual "&" when constructing the URL. (Please note that I had to represent "& amp;" with a space so that it does not get converted into it's HTML entity, so don't forget to remove the space when you copy into your code! Smile )

In SmartyColumnSort.class.php -- (~~ lines 56 & 61)
Code:

$nexturl .= $key.'[]='.$v.'&';

Code:

$nexturl .= $key.'='.$value.'&';


They will be converted to "& amp;" by Vacca's XHTML compliance which should also be simplified like this :

In function.columnsort.php -- (~~ line 141)
Code:

   if (strpos($url, '&'))    {
      $url = str_replace('&', '& amp;', $url);
   }




Also here is an unrelated patch that will automatically assign the first column as the default column

In SmartyColumnSort.class.php -- (~~line 67)

Code:

      if($column_array) {
         $this->setColumns($column_array);
         $this->setDefault($column_array[0], 'asc');
      }
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins All times are GMT
Goto page Previous  1, 2, 3, 4, 5, 6  Next
Page 2 of 6

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP