Closed (fixed)
Project:
Views Custom Field
Version:
6.x-1.x-dev
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
18 Nov 2008 at 19:21 UTC
Updated:
10 Mar 2011 at 13:42 UTC
Jump to comment: Most recent file
Comments
Comment #1
casey commentedIt uses PHP afterwards to generate row-specific text so its currently not possible.
Could you give some examples how you like to use it? Sort on what?
Comment #2
ipto commentedFor example have values row: 8 / 2, 10 / 5, 8 / 7, 3.4 / 2, 8 / 6 (before '/' - average fivestar value, after - voting user count), you need to sort this value as a string:
To do this, I glued them into one customfield field, but only now noticed that sort of pressing header in the table does not.
In views theming filles (\modules\views\theme\) I have full access to all views fields table, and just merge (or do other activities with them) they is not difficult without customfield :
Comment #3
casey commentedYou already can do this. Just add two sorts to your view; first on "average fivestar value" second on "voting user count".
Let me know if that's what you're looking for.
Comment #4
ipto commentedYes, ask if the criteria for grading in block vies, all appear as you want, but when you click on the header field tables default sorting break and starts sorting the field corresponding pressed headline, that is why I combine two fields (value_average and value_count) in one
Comment #5
casey commentedI could introduce a new customfield "fieldcombination" which combines two or more fields in the query; then it would be possible to sort on those fields.
But currently I don't have much time; I'll look into it next week.
Comment #6
casey commentedSorry don't have time for this on the moment.
Comment #7
asak commentedI'm using CustomField to calculate some user info, which results in a single or double digit number (e.g 1 or 3 or 24) - how can i get views to enable sorting by this results?
Comment #8
casey commentedYou can't, as customfields are evaluated after querying of the (sorted) result.
I have however some ideas to introduce some fields that allows to add calculations (or other sql functions) to a views query. Unfortunatly I don't have very much time right now; so it can take some time before this is implemented.
Comment #9
emagus commentedHey casey.
First of all: Thanks for your great module.
Reading this, i get the feeling this isn't gonna happen too soon, which i totally understand. It's a rather critical feature for me (and possibly many others). So it would be really nice if you could share your aforementioned ideas with us. Maybe someone who really needs this too and who is an experienced drupal developer is able to implement your ideas. And maybe, if i feel like it's easy enough for me, I will even try this myself (even though i'm very low skill on php and new to drupal development).
thanx in advance
Comment #10
infojunkieI use this module all the time, thanks for a great contribution.
Attached is a patch to provide sorting for PHP Code custom fields. I'd be happy if people here could use it and validate it, and if the module maintainer would consider committing it in. Since I need this for my professional (commercial) work, I'm willing to provide support for it. If it works well, I can extend this to Row Number field as well (I guess it doesn't make sense for Markup).
To activate sorting, just choose a sorting method in the field's settings. Make sure the fields in the Table style settings are marked as sortable.
Comment #11
casey commented@kratib For about a month I don't have time to work on my drupal modules. I could give you CVS access?
Comment #12
infojunkie@casey thanks for our offer. Go ahead and grant me CVS access. In any case I will wait to hear from people who tried the patch before committing it.
Did you get a chance to try the patch?
Comment #13
casey commentedCVS access granted.
No, don't have time for anything at all (working on a paper for my study with a short deadline and after that a couple of exams).
I was actually also working on a solution for this. My idea was to allow the usage of views sort handlers as clicksorts (configurable per custom field). Don't have it fully working yet though.
Comment #14
infojunkieRight now my patch is just for the field handler to be click sortable. I don't know what it takes to write a sort handler, so I'll wait for people to tell me which one they need.
Comment #15
emagus commented@kratib: Tested the patch and works perfectly fine so far for me! Thank you so much!!! Great job!
@casey: Thank you for giving kratib cvs access. That's true open source spirit! And also thanx for checking your issue queue despite your school stress!
Comment #16
infojunkieI just committed the above patch (tweaked for performance) to the latest dev release. I tested it on a view with 10K nodes so things look alright to me. Note that this applies to PHP custom field only, not Rownumber yet.
I'll keep this active until I commit a similar patch for Rownumber, which will probably require refactoring some code to a common ancestor of these two classes to avoid code duplication.
Comment #17
infojunkieFYI: I just found a bug that happens when the PHP code generates HTML to be rendered. I committed a fix to the latest dev.
Comment #18
ari-meetai commentedWell, this last commit would be great for me if it would work. I've tried with all sorting types and nothing.
I'm trying to show the user's first + last name, eg:
(tried also with simpler versions)
The output is correct, but I just can't sort... The column title doesn't appear as a link..
Any help appreciated.
Comment #19
infojunkieIf you're using table output, then you need to open the table settings and set this field as sortable. Does that apply?
Comment #20
ari-meetai commentedOh yes! Forgot that... Thank you for the quick answer!
Great job.
Comment #21
markus_petrux commented@kratib: Could you please add a note in the description of the sorting option to describe a little that sorting will load all records of the query in memory to resolve the sort? Please. On my installation there is staff that can create views and I have given this module to them, but they may try to against thousands of records.
I would even ask for an option to disable sorting for PHP fields, or maybe if there was a PHP field sortable, and another one that is not sortable, then we could use the later so that users cannot take the site down when creating and then running a view against a huge number of records.
Other than that, nicely done. ;-)
Thanks
Comment #22
infojunkie@markus_petrux: I added the warning note as a description to the field. It is easy to set the sorting option to none (which it is by default). Also, sorting in memory won't occur until the header of the custom field is actually clicked.
Comment #23
markus_petrux commentedThank you. This will save me one or two headaches.
Comment #24
tengokuhi.... thanks for the patch... it works on table outputs.... sadly i use de grid output.. and don't works.... u have to do something special to this??
Comment #25
infojunkieThe implemented feature is only for tables so far. To make it work for other styles, one has to implement sort handlers which is still not done. You can open a new feature request for it if you wish.
Comment #26
Bilmar commentedsubscribing
Comment #27
YK85 commentedsubscribing
Comment #28
Pidot commentednvm this post, the dev version contains a fix
if you use the patch, the behaviour changes:
for example if you insert this in your customfield:
<?PHP echo "<ul><li>bla</li><li>bla</li></ul>" ?>
it outputs the html code and it doesn't make a list...
Comment #29
infojunkieMarking as fixed. For bugs, please open new issues.
Comment #31
phyadmin commentedSo this patch has been tested and verified to work...yet it still hasn't been pushed to the production version of this module? What's the deal? If it works, megre it and add a module configuration settings page for this that makes it optional. If not, then don't mark the feature request as fixed. But a user shouldn't have to hunt down an old forum thread from X months ago just to add a feature.
Comment #32
wcndave commentedAlso, this patch is for custom field, however in D7 it's just called views php so needs to be ported to views php as well...