Hello everybody,

i just had to hide specific vocabularies in a Drupal v5.0 project and modified the CVS HEAD to fullfill the new module format. Thanks to frodo, who recently ported to 4.7, this has been relative easy.
But nevertheless, please check through the code and fix everything you can find. Especially my english isnt that good and the description/help is currently doubled.

Unfortunately i dont have cvs access, so maybe anyone can look through the code and commit it in my name if it is clean.

The attached file contains the complete v5.0 compatible module (New: taxonomy_hide.info, Changed: taxonomy_hide.module, Install.txt)

And here is the raw patch output:

<code>
diff U3 taxonomy_hide.module-orig taxonomy_hide.module
--- taxonomy_hide.module-orig	Fri Dec 29 00:24:17 2006
+++ taxonomy_hide.module	Fri Dec 29 00:28:11 2006
@@ -1,35 +1,56 @@
 <?php
 
-/* $Id: taxonomy_hide.module,v 1.6 2006/12/27 14:10:01 frodo Exp $ */
+/* $Id$ */
+
+
+function taxonomy_hide_menu($may_cache) {
+  $items = array();
+  if ($may_cache) {
+    $items[] = array(
+      'path' => 'admin/build/taxonomy_hide',
+      'title' => t('Taxonomy hide'),
+      'description' => t('Hide and group vocabulary terms in node views.'),
+      'callback' => 'drupal_get_form',
+      'callback arguments' => 'taxonomy_hide_admin_settings',
+      'access' => user_access('administer site configuration'), // or 'administer taxonomy'
+    );
+  }
+  
+  return $items;
+}
+
 
 function taxonomy_hide_help($section) {
   $output = '';
   switch ($section) {
-    case 'admin/modules#description':
-      $output = t('Hides and groups vocabulary terms in node views.');
+    case 'admin/build/taxonomy_hide':
+      $output = t('The taxonomy_hide module allows you to hide and group vocabulary terms in node views.');
       break;
+    
     case 'admin/help#taxonomy_hide':
-      $output = t('<p>The taxonomy_hide module allows you to hide and group vocabulary terms in node views.<p>'.
-                  '<p>When you view a node, you usually see all vocabulary terms it is associated with. Sometimes, you might want to hide terms of a specific vocabulary. This module allows you to specify the vocabularies whose terms are never displayed in node views.</p>'.
-		  '<p>The list of vocabulary terms is usually sorted first by vocabulary weight, and next alphabetically. So terms of different vocabularies with the same weight are mixed. This module allows you to group terms by vocabulary in node views, which means that all terms of one vocabulary are always next to each other.</p>'.
-		  '<p>You can</p>'.
-		  '<ul><li>Specify vocabularies whose terms will be hidden at %admin</li><li>Enable grouping of vocabulary terms at %admin</li></ul>',
-		  array('%admin' => l('administer >> settings >> taxonomy_hide', 'admin/settings/taxonomy_hide')));
+      $output = t(
+        '<p>The taxonomy_hide module allows you to hide and group vocabulary terms in node views.</p>'.
+        '<p>When you view a node, you usually see all vocabulary terms it is associated with. Sometimes, you might want to hide terms of a specific vocabulary. This module allows you to specify the vocabularies whose terms are never displayed in node views.</p>'.
+        '<p>The list of vocabulary terms is usually sorted first by vocabulary weight, and next alphabetically. So terms of different vocabularies with the same weight are mixed. This module allows you to group terms by vocabulary in node views, which means that all terms of one vocabulary are always next to each other.</p>'.
+        '<p>You can</p>'.
+        '<ul><li>Specify vocabularies whose terms will be hidden</li><li>Enable grouping of vocabulary terms</li></ul>'
+      );
       break;
   }
-
+  
   return $output;
 }
 
-function taxonomy_hide_settings() {
+function taxonomy_hide_admin_settings() {
+  $form = array();
   $form['taxonomy_hide'] = array(
     '#type' => 'fieldset',
     '#title' => t('Vocabulary settings'),
   );
-  if (!module_exist('taxonomy')) {
+  if (!module_exists('taxonomy')) {
     $form['taxonomy_hide'][] = array(
       '#type' => 'markup',
-      '#value' => l(t('Taxonomy module not enabled'), 'admin/modules')
+      '#value' => l(t('Taxonomy module not enabled'), 'admin/build/modules')
     );
   }
   else {
@@ -65,12 +86,12 @@
     );
   }
   
-  return $form;
+  return system_settings_form($form);
 }
 
 
 function taxonomy_hide_nodeapi(&$node, $op, $arg = 0, $arg2 = 0) {
-  if (!module_exist('taxonomy')) {
+  if (!module_exists('taxonomy')) {
     return;
   }
   
@@ -79,16 +100,16 @@
       # Get all hidden vocabularies; keys of $hidden are the vocabulary ids.
       $hidden = array_filter(variable_get('taxonomy_hide_vocabularies', array()));
       if (count($hidden)) {
-	# Hide terms by removing them from the taxonomy field
-	foreach ($node->taxonomy as $key => $value) {
-	  if (array_key_exists($value->vid, $hidden)) {
-	    unset($node->taxonomy[$key]);
-	  }
-	}
+        # Hide terms by removing them from the taxonomy field
+        foreach ($node->taxonomy as $key => $value) {
+          if (array_key_exists($value->vid, $hidden)) {
+            unset($node->taxonomy[$key]);
+          }
+        }
       }
       if (variable_get('taxonomy_hide_group_by_vocabulary', 0)) {
-	# Sort terms by sorting the taxonomy field
-	usort($node->taxonomy, "_taxonomy_hide_sort");
+        # Sort terms by sorting the taxonomy field
+        usort($node->taxonomy, "_taxonomy_hide_sort");
       }
       break;
   }
@@ -143,5 +164,3 @@
 }
 
 # vim:ft=php sw=2
-
-?>

CommentFileSizeAuthor
#3 taxonomy_hide_0.patch7.84 KBkeve
taxonomy_hide.zip2.79 KBkleingeist

Comments

drupalworld’s picture

ThANKS A LOT FOR THIS PATCH...IT WORKS PERFECTLY :)
Drupalworld

drupalworld’s picture

Hi, This module was working fine until I started to use the book module... then, when I try to create a book page, I ge tthe following message:


    * warning: Invalid argument supplied for foreach() in /home/expat9/www/sites/all/modules/taxonomy_hide/taxonomy_hide.module on line 104.
    * warning: Invalid argument supplied for foreach() in /home/expat9/www/sites/all/modules/taxonomy_hide/taxonomy_hide.module on line 104.
    * warning: Invalid argument supplied for foreach() in /home/expat9/www/sites/all/modules/taxonomy_hide/taxonomy_hide.module on line 104.
    * warning: Invalid argument supplied for foreach() in /home/expat9/www/sites/all/modules/taxonomy_hide/taxonomy_hide.module on line 104.

 

Any ideas?
I am using drupal 5.1 of course :)
Many thanks,
Drupalworld

keve’s picture

StatusFileSize
new7.84 KB

Corrected bug above.

I also removed module_exists(), since module dependency is defined in .info file.

pathscollide’s picture

I can't get keve's patch to work! If I attempt to patch kleingeist's module, I get the following errors:

patching file taxonomy_hide.module
Hunk #1 FAILED at 1.
Hunk #2 FAILED at 151.
2 out of 2 hunks FAILED -- saving rejects to file taxonomy_hide.module.rej

pathscollide’s picture

OK, apologies for my ignorance. I was trying to patch the wrong thing. Keve's patch applies to this: http://cvs.drupal.org/viewcvs/drupal/contributions/modules/taxonomy_hide...

summit’s picture

Hi,

Could someone make the taxonomy_hide drupal 5 tree and make the cvs?
Now I saw that the patch above is not related to the beginning of this thread.

Thanks in advance,
greetings,
Martijn

yoroy’s picture

I'd love to be able to use this in drupal 5 as well. The correct patches are already here it seems, just never finalised into a release for version 5. I tried put patching scares me…

yoroy’s picture

Actually, the .zip attached at the top does work. Great!

david lesieur’s picture

Version: master » 5.x-1.x-dev
Status: Needs review » Fixed

Committed and branched for Drupal 5! The package should be available shortly. Thanks for the patches!

Anonymous’s picture

Status: Fixed » Closed (fixed)
summit’s picture

Title: Support Drupal 5.0 » Bug foreacht for Drupal 5.2
Category: feature » bug
Status: Closed (fixed) » Active

Hi,

I activate this bug again. I am using drupal 5.2.
I got:

warning: Invalid argument supplied for foreach() in /home/public_html/modules/taxonomy_hide/taxonomy_hide.module on line 104. 

May be it has to do with a clitch in a node, but I can't find the node which has a clitch.
Shouldn't there be a check that prevents this bug to arise?

Greetings,
Martijn

summit’s picture

Title: Bug foreacht for Drupal 5.2 » Bug foreach for Drupal 5.2
Status: Active » Closed (fixed)

I solved my bug by filtering on taxonomy vocabulary.
It is still the case off course that the check for nodes should be there do this error can't emerge.
I close this issue again.

greetings,
Martjin

liquidcms’s picture

sadly this module doesn't seem to work with the category.module