Need help: Add 'Number of Post' and 'Contact Link' as fields to views
smitty - November 30, 2008 - 09:33
| Project: | Usernode |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Description
This patch adds two additional views-fields to usernode:
1. 'Number of Posts' shows the number of postings of a user. Thereby the number of nodes concerning the user-profile (that is the usernode and all nodes belonging to nodeprofile - if installed) do not count.
2. 'Contact Link' shows a Link to the build in contact form of a user - if the contact module is enabled. If the user hasn't enabled his personal contact form 'not enabled' is displayed. The look and feel of the link is themeable using a theme function.
Please feel free to make improvements.
| Attachment | Size |
|---|---|
| usernode_fields.patch | 3.08 KB |

#1
#2
Here comes a new patch for this issue. What has changed:
1. 'Contact Link' : I've seen that in Drupal the contact page is only available for logged in users. So for an anonymous user now is displayed: "Login or register to contact".
2. 'Number of Posts': It was not possible to sort the column 'Number of Posts' because the field is UID and so the view is sorted according to ‘uis’ instead according to ‘numberposts’. I tried to insert a sort_handler in the field and a handler in the sort-array. These handlers are called correctly (I tested this by inserting dummy code into the handlers).
But now I need help! I've no idea what code to insert into the handlers to get the views sorted according to ‘numberposts’ (which is calculated in usernode_views_handler_field_numberposts)
It would be very kind if anybody could give me some hints! Thank you!
#3
Really nobody who can help?
#4
I'm afraid I cannot offer any help, but I would offer encouragement since I am among the many people who are looking for the ability to put a user contact link into a user view. It's not hard to show a contact link for all displayed users*, but selectively showing it only when the displayed user has checked the contact box for his account, and only when the current user's role has permissions to access the contact form - that's not possible currently as far as I can tell (views2, D6).
* Add a field for user:uid; check "output this field as a link"; link path: "user/[uid]/contact"
#5
Thanks for the encouragement!
The patch #2 offers exactly what you need. The contact link is only shown if the user has enabled the contact form and if the current user is logged in.
But further on I need help with sorting the number of posts.
#6
@pdcarto #4 Thank You! have been messing with this for many hours, now is fixed.
Was attempting to use the "link to users contact form", but it was not showing for anonymous users even with permissions set for the field. Rebuilt permissions, clear cache, still would not work.
Although I like the little e-mail icon better, problem has been solved.
Thanks again..