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.

CommentFileSizeAuthor
#2 usernode_fields_2.patch4.76 KBsmitty
usernode_fields.patch3.08 KBsmitty
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

smitty’s picture

Status: Active » Needs review
smitty’s picture

Title: Add 'Number of Post' and 'Contact Link' as fields to views » Need help: Add 'Number of Post' and 'Contact Link' as fields to views
Status: Needs review » Needs work
FileSize
4.76 KB

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!

smitty’s picture

Really nobody who can help?

pdcarto’s picture

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"

smitty’s picture

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.

dbeall’s picture

@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..

BrianLewisDesign’s picture

Title: Need help: Add 'Number of Post' and 'Contact Link' as fields to views » Views: User Contact Link workaround

Or 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>

Pomliane’s picture

Status: Needs work » Closed (won't fix)

This 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.