Hi, I tried this now with several version of privatmsg (7.1 - 7.x-2.x-dev) - but I don't find a way to solve my problem ....

I want to create a list of users with views. In the table, I also want to include a link (directmessage) using the privatemsg_link-field.
But, if the user disabled directmessage, I want to show a corresponding message.
Normal views field can be rewrited. E.g. if there is no value, I can include a message directly in the "no value" section of the field. Privatemsg seems not to offer this. Also there is no way to exclude this field through views field settings.

Can anyone give me a hint on how to solve this problem?
Thanks in advance!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gregloby’s picture

I assume that you thought about privatemsg not "directmessage". If so you can update your view's table with jQuery. For every user who disabled privatemsg the module simple leave the proper table cell empty. So hint is: find the empty cells and update their content to the desired one.

$('td.views-field-privatemsg-link').each( function() {
   if ($(this).children().length == 0) {
      $(this).text('disabled');
   }
});
vistree’s picture

Hi gregloby,
thank you for your hint. Unfortunatelly this does not work. If the privetemsg-field is not rendered, I don't have the .views-field-privatemsg-link-class in my code. I don't use a table format. Instead I use an unordered list.
Any idea on this?

gregloby’s picture

Hi @vistree, hint is still the same
add custom "row_class" to your Unordered list settings in your view.
Then, with jQuery, look through your rows to find Send message or anything else you set up in your "Text to display" of privatemsg link field, and then add anything you want for each row which doesn't have a privatemsg link.

$('.row_class').each( function() {
		if (!$(this).find('a:contains("Send message")').length) {
			$(this).append('disabled');
		}
	});	

It works.

vistree’s picture

Thank you again!!!
Adding an extra class (instead of using the views-filed-privatemsg-link-class) did the trick!!!!!!

Brolag’s picture

Hi guys!

I couldn't hide the field from settings either so I wrote a patch that adds the exclude option to views_handler_field_privatemsg_link, might be useful for you too.

Cheers!

Brolag.

Brolag’s picture

Issue summary: View changes
Status: Active » Needs review
ivnish’s picture

Status: Needs review » Closed (outdated)
andypost’s picture

Status: Closed (outdated) » Needs review