Display terms only if associated with a node

Having fought with the problem of showing child terms for a given taxonomy term in a block, I finally stumbled on a piece of code that does exactly what I want.

As per the instructions I've added the following to my template.php

function themename_child_terms($vid = 1) {
  if(arg(0) == 'taxonomy' && arg(1) == 'term') {   
    $children = taxonomy_get_children(arg(2), $vid);
      if(!$children) {
        $custom_parent = taxonomy_get_parents(arg(2));
          $parent_tree = array();
          foreach ($custom_parent as $custom_child => $key) {
            $parent_tree = taxonomy_get_tree($vid, $key->tid);
          }
          $children = $parent_tree;
      }

    $output = '<ul>';
    foreach ($children as $term) {
      $output .= '<li>';
      $output .= l($term->name, 'taxonomy/term/' . $term->tid);
      $output .= '</li>';
    }
    $output .= '</ul>';

    return $output;
  }
}

I've then created a block and added :

<?php // $vid is the vocabulary id.
    print themename_child_terms($vid = 1);
?>

This shows the child terms of the current term perfectly. However, it shows ALL terms that exist under the parent term, even if there is no piece of content using that term.

e.g. viewing the page with all items in Term 1, I get

child 1
child 2
child 3

Snippet to display a list of nodes that an image is attached to?

I have an image gallery in a D6 e-commerce site which just shows image nodes. They look good but there's no connection between the images and the products they illustrate. The images are also attached to product nodes around the site. Is it possible to use PHP to automatically list the nodes to which each image node is attached, either within the body field of the image node or in a block which gets displayed on all the image node pages?

restore admin

I don't Know which version of Drupal I have but I have lost admin control to www.eratv.org and am denied access
My other username supertooth states it not been activated or is blocked.
Although my email address is registered and already taken try to Create new account, when I Request new password the reply is "Sorry, supertooth@yndk.info is not recognized as a user name or an email address"

Can someone offer some help as I am IT illiterate

Making nice menus more user friendly when a drupal site is viewed on a smart phone

Hi all!

My site (www.localtennisleagues.com) uses nice menus as the main way to navigate from the home page. It works well on conventional browsers, but on smart phones (I use Chrome as my browser) the way the menus are anchored (the fly outs link to the sections of the site but the menu itself is linked to the home page it appears on) isn't compatible with the touch screens of smart phones etc. Basically on a smart phone you just go round in circles.

Ubercart and Ubercart User Points

I was contacted by a new client to update the modules they had on their Drupal 6.28 web site. I have done so but having an issue with one of the modules and the report it gives. They are using Ubercart 6.x-2.11 and Ubercart User Points 6.x-2.--beta2.

Before the update the Invoice generated in Ubercart showed the Points the user has. Now that I have updated the modules that display seems to be no longer working. They had a few other custom fields they had added to the invoice which I ported over with no problem. But the user points shows 0 for each client and I know that is not correct. I am logged in as an editor and I have no points and I am wondering if it is showing my points instead of the client that made the order.

The original document was client_customer.itpl.php and the code for showing customer points was:

<tr>
                <td nowrap="nowrap">
                  <b><?php echo t('Allotment Balance:'); ?></b>
                </td>
                <td width="98%">
                  [order-userpoints-dollars] ([order-userpoints] points)
                </td>
              </tr>

In the updated module the file is now called uc_order-customer.tpl.php and the code is


echo t('Allotment Balance:');

Pages

Subscribe with RSS Subscribe to RSS - Drupal 6.x