DrupalBin
Submit Code
About
Recent Posts
Code
Fix for Fix for Code
Fix for Code
Code
Node type whitelist
an axe coach accessories
coach purses married
Fix for de las ghd alturas
de las ghd alturas
Code
more
User login
Log in using OpenID:
What is OpenID?
Username:
*
Password:
*
Log in using OpenID
Cancel OpenID login
Create new account
Request new password
Tags
CCK
drupal
fapi
jquery
menu
module
php
simpletest
taxonomy
test
theme
views
more tags
Home
Fix for Dynamically changing menu items on !$may_cache
View
Fix
May 29, 2009 - 9:28am — Anonymous
foreach
(
taxonomy_get_vocabularies
(
)
as
$vocabulary
)
{
if
(
_taxonomy_navigation_is_supported
(
$vocabulary
)
&&
variable_get
(
'taxonomy_navigation_show_'
.
$vocabulary
-
>
vid
,
0
)
)
{
// get parent settings
$pid
=
variable_get
(
'taxonomy_navigation_pid_'
.
$vocabulary
-
>
vid
, 0
)
;
$tree
=
taxonomy_get_tree
(
$vocabulary
-
>
vid
)
;
// build an array which holds all children of current term. necessary to build a proper 'or' value in the HREF
foreach
(
$tree
as
$term
)
{
$count
=
0
;
if
(
variable_get
(
'taxonomy_navigation_nodes_'
.
$vocabulary
-
>
vid
, TAXONOMY_NAVIGATION_DEFAULT_NUMBER_OF_NODES
)
)
{
$count
= _taxonomy_navigation_count
(
$term
-
>
tid
,
variable_get
(
'taxonomy_navigation_depth_'
.
$vocabulary
-
>
vid
,
'all'
)
)
;
}
if
(
(
$alias
=
drupal_get_path_alias
(
'taxonomy/term/'
.
$term
-
>
tid
)
)
!
=
'taxonomy/term/'
.
$term
-
>
tid
)
{
$item
=
array
(
'path'
=
>
drupal_get_path_alias
(
'taxonomy/term/'
.
$term
-
>
tid
)
,
'title'
=
>
theme
(
'taxonomy_navigation_menu_title'
,
$term
,
$count
)
,
'access'
=
>
TRUE
,
'type'
=
>
MENU_NORMAL_ITEM
,
'weight'
=
>
variable_get
(
'taxonomy_navigation_weight_'
.
$vocabulary
-
>
vid
, -20
)
+
$term
-
>
weight
,
'tid'
=
>
$term
-
>
tid
,
)
;
if
(
$pid
!
=
0
)
{
// If term has no parent, it means it's a root term
if
(
array_sum
(
$term
-
>
parents
)
== 0
)
{
$item
[
'pid'
]
=
$pid
;
}
}
$items
[
]
=
$item
;
$items
[
]
=
array
(
'path'
=
>
'taxonomy/term/'
.
$term
-
>
tid
,
'title'
=
>
t
(
$term
-
>
name
)
.
$out
,
'callback'
=
>
'taxonomy_navigation_page'
,
'callback arguments'
=
>
array
(
$term
-
>
tid
,
variable_get
(
'taxonomy_navigation_depth_'
.
$vocabulary
-
>
vid
,
'all'
)
)
,
'access'
=
>
user_access
(
'access content'
)
,
'type'
=
>
MENU_CALLBACK
,
'tid'
=
>
$term
-
>
tid
,
)
;
}
}
}
}
menu
pathauto
taxonomy
Submit Fix
Summary:
Tags:
Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Show summary in full view
foreach (taxonomy_get_vocabularies() as $vocabulary) { if (_taxonomy_navigation_is_supported($vocabulary) && variable_get('taxonomy_navigation_show_' . $vocabulary->vid, 0)) { // get parent settings $pid = variable_get('taxonomy_navigation_pid_' . $vocabulary->vid, 0); $tree = taxonomy_get_tree($vocabulary->vid); // build an array which holds all children of current term. necessary to build a proper 'or' value in the HREF foreach ($tree as $term) { $count = 0; if (variable_get('taxonomy_navigation_nodes_' . $vocabulary->vid, TAXONOMY_NAVIGATION_DEFAULT_NUMBER_OF_NODES)) { $count = _taxonomy_navigation_count($term->tid, variable_get('taxonomy_navigation_depth_' . $vocabulary->vid, 'all')); } if ( ( $alias = drupal_get_path_alias('taxonomy/term/' . $term->tid) ) != 'taxonomy/term/' . $term->tid ) { $item = array( 'path' => drupal_get_path_alias('taxonomy/term/' . $term->tid), 'title' => theme('taxonomy_navigation_menu_title', $term, $count), 'access' => TRUE, 'type' => MENU_NORMAL_ITEM, 'weight' => variable_get('taxonomy_navigation_weight_' . $vocabulary->vid, -20) + $term->weight, 'tid' => $term->tid, ); if ( $pid != 0 ) { // If term has no parent, it means it's a root term if (array_sum($term->parents) == 0) { $item['pid'] = $pid; } } $items[] = $item; $items[] = array( 'path' => 'taxonomy/term/' . $term->tid, 'title' => t($term->name).$out, 'callback' => 'taxonomy_navigation_page', 'callback arguments' => array($term->tid, variable_get('taxonomy_navigation_depth_' . $vocabulary->vid, 'all')), 'access' => user_access('access content'), 'type' => MENU_CALLBACK, 'tid' => $term->tid, ); } } } }
Syntax highlighting mode:
ActionScript
ColdFusion
Diff
Drupal 5
Drupal 6
HTML
INI
Javascript
MySQL
PHP
Python
robots.txt
SQL
Text
Select the syntax highlighting mode to use.
See Also:
Order
Title:
URL:
-1
0
1
Title:
URL:
-1
0
1
Any links you'd like to have associated with the post (Drupal.org issue, Wikipedia article, etc).
File attachments
Changes made to the attachments are not permanent until you save this post. The first "listed" file will be included in RSS feeds.
Attach new file:
The maximum upload size is
1 MB
. Only files with the following extensions may be uploaded:
jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp phps
.