From ThinkyWiki

Jump to: navigation, search

Photobar Using Images From Nodes

The Photobar module will provide a "Photobar" block that displays an image based on the current path. The image or images are supplied by a CCK image field added to any node type, or come from image attachments. Images attached to a particular node - for example a Page - are displayed not only for that node, but for any imageless nodes with a child URL alias. The block can be configured to only consider nodes that are in the menu tree.

This will be implemented as a block module. The block will use the current path to look up the current page node and get its image. If it has no image it will look up the parent path and see if any node exists there, and so on up until it finds a node with an image. If no image is found it uses the home page's image. And if that doesn't exist either it uses a default image. Finally it prints theme('image') with the image url, or it uses an ImageCache image. If there are multiple images, it can show them in a jQuery slideshow.

Things to solve:

  • How to get the node for the current path
  • How to get the current secondary menu tree
  • How to recurse through the menu tree to get parent items
  • How to implement a block in Drupal 6

Issues to watch out for:

  • In hook_block numerical keys (deltas) may not work. Use non-numerical keys if this problem crops up.
  • Menus in Drupal are independent constructions so that you can do anything you want with them. Menu items aren't tied to pages or nodes or views at all. No individual content item cares that it happens to be referred to in some menu. But menus are useful to provide things like photos based on a hierarchy or data sources for breadcrumbs.

Photobar Standalone

A standalone Photobar would implement all the necessary functions within a single block for use throughout the site, or could supply multiple blocks, but everything managed from the Photobar settings page. Functions needed:

  • Upload images and store them in files/photobar/[bar-id]
  • Choose the site path where each image will appear
  • Choose the ImageCache setting that will best fit the block
  • For multiple image blocks, choose the order in which images appear
Personal tools