Download & Extend

Link to "faces" in OG's members count column in Views should be configurable

Project:Organic groups
Version:6.x-2.x-dev
Component:Og Views
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs work

Issue Summary

When I display a list of Groups, the numbers under the "members" column are linked to the "Faces" page, which I don't like at all.

Also the block "Group details" has this link, and I'd like to remove it in both instances. I ask for help because I wasn't able to do it.

In Views' "members count" field definitions, I can't see any "link" checkbox. And I'm not sure where I can modify the Group details block.

Thank you
Alejandro.

Comments

#1

Ooff... All I was able to do was in drupal/modules/og/modules/og_views, modify...

- function og_views_og_links_alter(&$links, $node) in og_views.module
- function render($values) in includes/og_views_handler_field_og_member_count.inc

...in order to make the links empty strings ("") in the line where og_is_picture() appears.

I know it's stinky, if anyone has an insight or a solution. Thank you.

Alex.

#2

Title:Remove FACES» Remove link to "faces" in OG's members count column in Views

#3

Component:og.module» Og Views

#4

Category:feature request» support request

Sorry about all these changes to the issue... was in a hurry when I posted this.

Still need an answer! ;-)

#5

Title:Remove link to "faces" in OG's members count column in Views» Link to "faces" in OG's members count column in Views should be configurable
Category:support request» feature request

This is hardcoded, unfortunatly. It was still displayed even after I disabled og_members_faces view, disabled 'og/users/%node/faces' path in hook_menu_alter(). Seems like the only way to fix it is to write own Views handler and use it instead of "og_views_handler_field_og_member_count". I can do it but most users can't.
This is one of times when I think using good framework such as Django would be much better (what good of CMS if too much stuff is hardcoded). It must be configurable.

#6

subscribing of course

#7

Status:active» closed (works as designed)

You just need a small module whose weight is higher than og_views. This is untested. Stick it in a file called no_faces_please.module.

<?php
// An implementation of hook_og_links_alter().
// Hyperlink the members count to the members listing.
function no_faces_please_og_links_alter(&$links, $node) {
  if (isset($links['subscribers'])) {
    $txt = strip_tags($links['subscribers']);
    $links['subscribers'] = l($txt, "og/users/$node->nid");
  }
}

Here's your no_faces_please.info file:

name = No faces please
description = "I do not want faces."
package = "Organic groups"
dependencies[] = og
dependencies[] = views
dependencies[] = og_views
core = 6.x
version = "6.x-0.1"

And, here is your no_faces_please.install file:

<?php
/**
* Implementation of hook_install().
*/
function no_faces_please_install() {
  // Increase module weight to 10 to make sure it's higher than og_views
  db_query("UPDATE {system} SET weight = 10 WHERE name = 'no_faces_please'");
}

Don't forget to thank Moshe and Amitaibu for all their work on these modules.

There are lots of other ways to get around this. Search for og_links_alter and/or hook_og_links alter -- someone has probably already posted this solution.

[Edit: there were a few typos in the initial version of this. They're fixed now, but this is still untested code.]

#8

Status:closed (works as designed)» active

And how hook_og_links_alter() is going to help when this link is printed by Views handler ?
Also setting "by design" on feature request makes no sense: new features are meant to change design. Feature requests are aither active, fixed or "won't fix".

#9

Posting my code, but this must be fixed in og_views module itself. We shouldn't write code for such simple feature.

This goes into "includes/custom_handler_field_og_member_count.inc" of your "custom" module

<?php
class custom_handler_field_og_member_count extends og_views_handler_field_og_member_count {
  function
render($values) {
   
$nid = $values->nid;
   
$txt = $values->member_count;
    if (
og_is_group_member($nid)) {
     
//$value = og_is_picture() ? l($txt, "og/users/$nid/faces") : l($txt, "og/users/$nid");
     
$value = $txt;
      return
check_plain($this->options['prefix']) . $value . check_plain($this->options['suffix']);
    }
    else {
      return
parent::render($values);
    }
  }
}
?>

This goes into your "custom" module.

<?php
/**
* Implementation of hook_views_api().
*/
function custom_views_api() {
  return array(
   
'api' => 2,
  );
}
?>

And this goes into custom.views.inc inside your "custom" module:

<?php
// $Id$

/**
* @file
* Defines Custom Views data and plugins.
*
*/

/**
* Implementation of hook_views_handlers() to register all of the basic handlers
* views uses.
*/
function custom_views_handlers() {
  return array(
   
'info' => array(
     
'path' => drupal_get_path('module', 'custom') .'/includes',
      ),
   
'handlers' => array(
     
'custom_handler_field_og_member_count' => array(
       
'parent' => 'og_views_handler_field_og_member_count',
      ),
    ),
  );
}


/**
* Implementation of hook_views_data_alter().
*/
function custom_views_data_alter(&$data) {
 
$data['og']['member_count']['field']['handler'] = 'custom_handler_field_og_member_count';
}
?>

This fixes og view (group directory view) - member count will be plain text number.

#10

@crea - did you test the code from #7?

#11

Nope, why would I blindly copy-paste some random snippet, while I know it wouldn't work ?
Specially for you I have made search on "drupal_alter('og_links'" in OG module and it's being called only in og_block_details() function, completely unrelated to Views.

#12

Update: there is indeed alter hook so in my solution instead of custom_views_data() you must use following hook, and use existing field:
UPD2: I moved this code to #9

#13

@crea - Any chance you could supply a patch to og_views for this? The solution I posted will only work for the Group Details Block, not for the general case.

I apologize for changing the status -- this isn't my project to manage, so I shouldn't have done that.

#14

If I could I would implement such setting straight instead of overriding handler. I don't know Views good enough to supply such patch, and also I don't know what would be proper way from the point of OG maintainer.

#15

Any new ideas about this? I pretty much made my own views in OG with great result but I need to disable the "faces functionality" some way.

#16

You can disable the view and then use the following in your module:

<?php
function mymodule_menu_alter(&$items) { 
 
// Disable OG Views path.
 
unset($items['og/users/%node/faces']);
?>

#17

@crea, it worked exactly the way i wanted it too, thanks a bunch for this!

#18

YESssssssssssss!!

#19

Are there any theming functions available to change the column are linked to the "Faces" page to instead link to the list page?

#20

#558134-9: Link to "faces" in OG's members count column in Views should be configurable and #558134-16: Link to "faces" in OG's members count column in Views should be configurable sorted me out.

I wanted to "output the field as a link", linking it to a "members/all" (from Open Atrium members). This was not possible until I incorporated this as cited.

Many thanks!

#21

Version:6.x-2.0» 6.x-2.x-dev
Category:feature request» bug report
Status:active» needs review

Here's a patch which adds the option. Based on node handler.

This is a bug IMO because it overwrites the link options without warning or reasonable workaround.

AttachmentSizeStatusTest resultOperations
og-og_views-member-count-link-558134-21.patch2.53 KBIgnored: Check issue status.NoneNone

#22

That patch wasn't quite right, tried to take a bigger hint from other 'core' views handlers in this one.

AttachmentSizeStatusTest resultOperations
og-og_views-member-count-link-558134-22.patch2.82 KBIgnored: Check issue status.NoneNone

#23

Status:needs review» reviewed & tested by the community

#22 works perfect!

#24

subscribing

#25

I give up. Where do I access the checkbox that the patch adds?

Thanks,
Mickey

#26

Status:reviewed & tested by the community» needs work

Reviewing #22:

  • The title and description of the new option are poorly worded and confusing outside the context of this issue.
  • render_link() seems easily confused with render_as_link(), since it is very specific might better as render_members_link().
  • Lastly, menu_get_item() is more expensive than og_is_group_member(). Don't see what's worth the performance hit.

@micnap this is added to the Member Count views handler. That means there is no option made available directly to users of Organic Groups, but rather you can customize the various listing views that use it.

That is a good architectural review for the change--since this really doesn't help anyone except advanced site builders/developers who are comfortable enabling the Views UI and making changes. Covering the group details block as well requires a tweak to og_views_og_links_alter(), which raises the idea of an OG setting for showing the link or not in the block. Might be overly-complex to use that as the default value for the new Views handler setting.

#27

Bumping the patch to 2.3 for those that need drush make files.

@Grayside still digesting you're specific concerns...

AttachmentSizeStatusTest resultOperations
og-og_views-member-count-link-558134-27.patch2.65 KBIgnored: Check issue status.NoneNone
nobody click here