It seems like path_to_theme() does not take work with submenus declared in hook_menu(). If I don't add the trick to check for an argument, the image will not print.

function my_menu($may_cache)
{
  // array of menu items
  $items = array();
  
  if ($may_cache)
  {
    $items[] = array(
      'title' => t('My'),
      'path' => 'my',
      'callback' => 'my_show',
      'type' => MENU_NORMAL_ITEM,
      'access' => TRUE
    );
    
    $items[] = array(
      'path' => 'my/own',
      'title' => t('My Own'),
      'callback' => 'my_show',
      'callback arguments' => array('an_argument'),
      'type' => MENU_NORMAL_ITEM,
      'weight' => 0
    );
}

function my_show($arg)
{
    $output .= '"<input type="image" class="image-button" src="';
  
  // a callback argument is passed from the submenu
  if ($arg != '')
  {
    $output .= '../';
  }
  
  $output .= path_to_theme() . '/images/image.png" align="top" /></form></div>';
}

Comments

jmlavarenne’s picture

Status: Active » Closed (fixed)