Project:Organic groups
Version:5.x-5.4
Component:og.module
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

Hi all,

I'm trying to modify the order of the links in the OG group block. I thought it would be customizable, but I could not find the way. So, I had to modify the og.module.

What I've done:

- In og_og_block_details function
- Change the simple array $links into a keyed array(with a description of the content)
- Insead of theme directly the items:

<?php
$block
['content'] = theme('item_list', $links). $post;
?>

- I pass it to another theme function where I can order the list
<?php
$block
['content'] = theme('og_og_block_details', $links, $post);
?>

- Add the new theme function:

<?php
function theme_og_og_block_details($links, $post) {
 
// assign the last default order
 
$keys_order = array('invite', 'menbers', 'manager', 'my-membership', 'request-message', 'request-delete', 'register-needed', 'suscribe', 'closed-message');
  foreach (
$keys_order as $link_name) {
    if (isset(
$links[$link_name])) {
     
$processed_links[] = $links[$link_name];
    }
  }
 
// include the post variable like the last default order
 
return theme('item_list', $processed_links). $post;
}
?>

- Change coherently og_og_create_links function

I include two patchs, one for 5.4 and the other for CVS today, if you want to examine it more.

Maybe there's a better way...

Cheers

AttachmentSizeStatusTest resultOperations
theme-og-group-block.5.4.patch3.98 KBIgnored: Check issue status.NoneNone
theme-og-group-block.cvs_.patch3.94 KBIgnored: Check issue status.NoneNone

Comments

#1

This seems like a good idea - I've been looking at the block too as I was trying to get the Create links into alphabetical order rather than node->type order

#2

Uppss.. today I review the code again.. disappearing bugs

The create content links are not there, so let's modify the theme function:

<?php
function theme_og_og_block_details($links, $post) {
 
// do not assign any order by default
 
$keys_order = array_keys($links);
 
// Maybe you want to do something like:
  //$keys_order = array('create-<mytype>', 'invite', 'suscriptors', 'manager', 'my-subscription', 'request-message', 'request-delete', 'register-needed', 'suscribe', 'closed-message');

 
foreach ($keys_order as $link_name) {
    if (isset(
$links[$link_name])) {
     
$processed_links[] = $links[$link_name];
    }
  }
 
// include the post variable like the last default order
 
return theme('item_list', $processed_links). $post;
}
?>

And change the string which is concatenated ( $links["create-$type->type"] ) in og_og_create_links function(do not allow spaces or something like that)

I've updated the patches:

AttachmentSizeStatusTest resultOperations
theme-og-group-block.5.4.patch4.08 KBIgnored: Check issue status.NoneNone
theme-og-group-block.cvs_.patch4.04 KBIgnored: Check issue status.NoneNone

#3

Thank you for the new patch. There are a couple of small typos I spotted

+    $links['suscriptors'] = $txt;

Should be
+    $links['subscribers'] = $txt;


-    $links[] = og_subscribe_link($node);
+    $links['suscribe'] = og_subscribe_link($node);

Should be
+    $links['subscribe'] = og_subscribe_link($node);

#4

Status:needs review» fixed

I added a hook_og_link_alter where you can fiddle with these links in the block ... You can also take over this block for each group type. See og_block_details().

#5

Thanks a lot.

I was wondering - if the alphabetical create content links is a general requirement could you perhaps see your way to adding an asort to the links array

function og_og_block_details($node) {
  global $user;

  list($txt, $subscription) = og_subscriber_count_link($node);

  if ($subscription == 'active' || user_access('administer nodes')) {
    $links = module_invoke_all('og_create_links', $node);
+    asort($links);

#6

that would not sort on the text of the link. is a bit more complicated.

#7

Thanks for including the feature Moshe.

#8

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

#9

Status:closed (fixed)» active

Hi,

Thanks for the info, I'm trying to get info on this subject of modifying the 'create content' links on my og pages.

However, I don't really understand 100%.

Also read this from Moshe:

<?php
function phptemplate_og_links_alter(&$links) {
// change $links as desired.
}
?>

but I don't know what to put in the change $links part!

I think some clearer details on how to alphabetise the list, or be more selective with ordering, would be *really* useful. Sorry if this is obvious, would be happy to read instructions elsewhere, but just can't find them.

Thanks mate

#10

Status:active» closed (fixed)

I have provided he OG specific information on this task. What you need now is knowledge about how to sort or reorder an array which is a PHP skill. Can't provide generic PHP support here.

nobody click here