Hierarchical Select Node Reference

Last modified: November 7, 2009 - 10:29

Overview

This module allows the use of Hierarchical Select form element as a widget for CCK node reference field, both in node add/edit form and in views filter.

Installation

See README.txt for detailed installation instructions

Example

Content Types

The example uses the following content types:

  1. Country
    • Name
  2. State
    • Name
    • Country: Content types = Country, Required, Number of values = 1
  3. City
    • Name
    • State: Content types = State, Required, Number of values = 1
  4. Address
    • Street
    • City: Content types = City, Required, Number of values = 1
  5. Customer
    • Name
    • Addresses: Content types = Address, Required, Number of values = 5
  6. Order
    • ShippingAddress: Content types = Address, Required, Number of values = 1
    • Customer: Content types = Customer, Required, Number of values = 1
    • TaxZone: Content types = TaxZone, Required, Number of values = 1
  7. LineItem
    • Order: Content types = Order, Required, Number of values = 1
    • Product: Content types = Product, Required, Number of values = 1
    • Amount
  8. Product
    • Name
    • MadeBy: Content types = State or Country, Optional, Number of values = 1
    • Warehouse: Content types = Address, Required, Number of values = 1
  9. TaxZone
    • Tax
    • Zone: Content types = Address or City or State or Country, Required, Number of values = 10

Node reference paths

Give the content types listed above, the following node reference paths are possible:

  1. LineItem.Order-Order.ShippingAddress-Address.City-City.State: Number of values = 1 and single content types at all levels
  2. Customer.Addresses-Address.City-City.State: Number of values > 1 at root
    • This is used to test dropbox in node reference field widget
  3. TaxZone.Zone-City.State-State.Country: Number of values > 1 & multiple content types at root
    • This is used to test save lineage in node reference field widget
  4. Product.MadeBy-State.Country: Number of values = 1 & multiple content types at root
  5. Order.Customer-Customer.Addresses-Address.City-City.State: Number of values > 1 at non-root
  6. Order.TaxZone-TaxZone.Zone-City.State-State.Country: Number of values > 1 & multiple content types at non-root
    • When using this path as node reference field widget, it can only select tax zones containing a city
    • Similarly when using this path as views filter, it can only filter zones containing a city
    • Current implementation can only select an item from the last level in the path, future enhancement is needed to allow selection from middle levels
  7. LineItem.Product-Product.MadeBy-State.Country: Number of values = 1 & multiple content types at non-root
    • Similar to #6, when using this path as field widget/views filter, it can only select/filter products made by a state (not by country)

Usage Screenshots

CCK Node Reference Field

  1. See http://drupal.org/node/626096 for a screenshot of the field setting for path "Order.TaxZone-TaxZone.Zone-City.State-State.Country". Please note in order for the "Node reference path" to work, "Content types that can be referenced" must be saved first.
  2. See http://drupal.org/node/626070 for a screenshot of the resulting field widget in an order edit form, note the order of the dropdowns in the widget is the reverse of the node reference path.

Views Filter

  1. See http://drupal.org/node/626098 for a screenshot of the extra setting form when you attempt to add a filter for Content: Tax Zone node reference field
  2. See http://drupal.org/node/626100 for a screenshot of the filter setting for path "Order.TaxZone-TaxZone.Zone-City.State-State.Country"
  3. See http://drupal.org/node/626102 for a screenshot of the views filter in action in live preview

 
 

Drupal is a registered trademark of Dries Buytaert.