Closed (fixed)
Project:
Taxonomy hide
Version:
5.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
28 Dec 2006 at 23:32 UTC
Updated:
11 Dec 2007 at 22:21 UTC
Jump to comment: Most recent file
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
-
-?>
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | taxonomy_hide_0.patch | 7.84 KB | keve |
| taxonomy_hide.zip | 2.79 KB | kleingeist |
Comments
Comment #1
drupalworld commentedThANKS A LOT FOR THIS PATCH...IT WORKS PERFECTLY :)
Drupalworld
Comment #2
drupalworld commentedHi, 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:
Any ideas?
I am using drupal 5.1 of course :)
Many thanks,
Drupalworld
Comment #3
keve commentedCorrected bug above.
I also removed module_exists(), since module dependency is defined in .info file.
Comment #4
pathscollide commentedI 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
Comment #5
pathscollide commentedOK, 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...
Comment #6
summit commentedHi,
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
Comment #7
yoroy commentedI'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…
Comment #8
yoroy commentedActually, the .zip attached at the top does work. Great!
Comment #9
david lesieur commentedCommitted and branched for Drupal 5! The package should be available shortly. Thanks for the patches!
Comment #10
(not verified) commentedComment #11
summit commentedHi,
I activate this bug again. I am using drupal 5.2.
I got:
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
Comment #12
summit commentedI 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
Comment #13
liquidcms commentedsadly this module doesn't seem to work with the category.module