Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#2 | usernode_fields_2.patch | 4.76 KB | smitty |
usernode_fields.patch | 3.08 KB | smitty |
Comments
Comment #1
smitty CreditAttribution: smitty commentedComment #2
smitty CreditAttribution: smitty commentedHere 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!
Comment #3
smitty CreditAttribution: smitty commentedReally nobody who can help?
Comment #4
pdcarto CreditAttribution: pdcarto commentedI'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"
Comment #5
smitty CreditAttribution: smitty commentedThanks 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.
Comment #6
dbeall CreditAttribution: dbeall commented@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..
Comment #7
BrianLewisDesign CreditAttribution: BrianLewisDesign commentedOr just rewrite the [iud] field in views (and don't forget permissions):
relationship - Content:Author
field - Content: Author uid
- REWRITE RESULTS - Rewrite the output of this field [X]
<a href="?q=user/[iud]/contact">Send Email</a>
Comment #8
Pomliane CreditAttribution: Pomliane commentedThis version of Usernode is not supported anymore. The issue is closed for this reason.
Please upgrade to a supported version and feel free to reopen the issue on the new version if applicable.
This issue has been automagically closed by a script.