Image menu
in Project codes
This CodeLet will allow you to add an image to a menu by overriding the menu in the template.php file of you theme. Also, the module offer admin side control to select and put the image to a menu item.
<?php
//$ID$
/**
*
* @file
*
* Manage drupald navigation
*
* hook = drupald_navigation
*
* @author Drupal Developer <http://twitter.com/DrupalD>
*/
/**
* Implementation of hook_help
*
*
* @author Drupal Developer <http://twitter.com/DrupalD>
*/
function drupald_navigation_help($path) {
switch ($path) {
case 'admin/build/drupald-navigation':
$output = t("Here, you can control the CTA menu display.");
return $output;
case 'admin/build/drupald-navigation/add':
$output = t("Add CTA to menu");
return $output;
}
}
/**
* Implementation of hook_menu
*
* @author Bhavin H. Joshi <bhavin@viruteinfo.com>
*/
function drupald_navigation_menu() {
$item = array();
$item['admin/build/drupald-navigation'] = array(
'title' => 'drupald CTA Menu Configuration',
'title callback' => 't',
'page callback' => 'drupal_get_form',
'page arguments' => array('drupald_navigation_list'),
'access callback' => 'user_access',
'access arguments' => array('Administer site configuration'),
'weight' => 0,
);
$item['admin/build/drupald-navigation/list'] = array(
'type' => MENU_DEFAULT_LOCAL_TASK,
'title' => 'drupald CTA',
'title callback' => 't',
'page callback' => 'drupal_get_form',
'page arguments' => array('drupald_navigation_list'),
'access callback' => 'user_access',
'access arguments' => array('Administer site configuration'),
'weight' => -10,
);
$item['admin/build/drupald-navigation/add'] = array(
'type' => MENU_LOCAL_TASK,
'title' => 'Add CTA',
'title callback' => 't',
'page callback' => 'drupal_get_form',
'page arguments' => array('drupald_navigation_admin'),
'access callback' => 'user_access',
'access arguments' => array('Administer site configuration'),
'weight' => -9,
);
$item['admin/build/drupald-navigation/cta/%/%'] = array(
'type' => MENU_CALLBACK,
'page callback' => 'drupal_get_form',
'page arguments' => array('drupald_navigation_admin', 4, 5),
'access callback' => 'user_access',
'access arguments' => array('Administer site configuration'),
'weight' => -9,
);
$item['get/cta'] = array(
'type' => MENU_CALLBACK,
'page callback' => 'get_cta',
'page arguments' => array(2),
'access callback' => 'user_access',
'access arguments' => array('Administer site configuration'),
'weight' => 0,
);
$item['worldwide/node'] = array(
'type' => MENU_CALLBACK,
'page callback' => '_get_worldwide_node',
'page arguments' => array(2),
'access callback' => TRUE,
);
$item['import'] = array(
'type' => MENU_CALLBACK,
'page callback' => 'import_data',
'access callback' => TRUE,
'file' => 'import.inc.php',
'file_path' => drupal_get_path("module", 'drupald_navigation'),
);
return $item;
}
/**
* drupald_navigation_admin
*
* Manage & configure drupald CTA in menus
*
* @author Drupal Developer <http://twitter.com/DrupalD>
*/
function drupald_navigation_admin($form, $drupald_id = NULL, $op = NULL) {
$form = array();
if ($op) {
switch ($op) {
case 'edit':
$r__menu = db_query("SELECT * FROM {drupald_navigation} WHERE drupald_id = %d",
$drupald_id);
while ($om__menu = db_fetch_object($r__menu)) {
$ss__node_title = drupald_get_node_title($om__menu->nid) ." - ". t("node")
.": ". $om__menu->nid;
$ss__mlid = $om__menu->mlid;
list($width, $height) = preg_split("/(x|X)/", $om__menu->image_size);
if (!$height) {
$ss__imagecase_size = $width;
}
else {
$ss__size = $om__menu->image_size;
}
$sn_weight = $om__menu->weight;
}
break;
case 'status':
db_query("UPDATE {drupald_navigation} SET status = !status WHERE drupald_id = %d",
$drupald_id);
drupal_set_message(t("CTA status has been changed."));
drupal_goto($_GET['destination']);
break;
case 'delete':
db_query("DELETE FROM {drupald_navigation} WHERE drupald_id = %d", $drupald_id);
drupal_set_message(t("CTA has been deleted."));
drupal_goto($_GET['destination']);
break;
}
$form['drupald_id'] = array(
'#type' => 'hidden',
'#value' => $drupald_id,
);
$form['cta_update'] = array(
'#type' => 'submit',
'#value' => t("Update CTA menu"),
'#submit' => array('drupald_navigation_cta_update'),
'#weight' => 50,
);
}
else {
$form['cta_submit'] = array(
'#type' => 'submit',
'#value' => t("Add CTA to menu"),
'#submit' => array('drupald_navigation_cta_submit'),
'#weight' => 50,
);
}
$form['nodes'] = array(
'#type' => 'textfield',
'#title' => t("CTA node"),
'#description' => t("Search the CTA node"),
'#autocomplete_path' => ($op != 'edit') ? 'get/cta' : NULL,
'#default_value' => $ss__node_title,
'#disabled' => ($op == 'edit') ? TRUE : FALSE,
'#required' => ($op != 'edit') ? TRUE : FALSE,
);
$am__parent_menu = menu_get_menus(FALSE);
foreach ($am__parent_menu as $key => $value) {
$am__menu_tree = array_values(menu_tree_page_data($key));
foreach ($am__menu_tree as $k => $v) {
$am__menu[$value][$v['link']['mlid']] = $v['link']['title'];
}
}
$am__menu[0] = "-- ". t("Select menu") ." --";
$form['menus'] = array(
'#type' => 'select',
'#title' => t("Menu"),
'#options' => $am__menu,
'#description' => t("Select the menu, the CTA should appear in"),
'#default_value' => ($ss__mlid) ? $ss__mlid : 0,
'#required' => TRUE,
);
if (module_exists('imagecache')) {
$presets = imagecache_presets();
foreach ($presets as $preset) {
$am__preset[$preset['presetid']] = $preset['presetname'];
}
$am__preset[0] = "-- ". t("Select preset") ." --";
$form['cta_size'] = array(
'#type' => 'select',
'#title' => t("Imagecache presets"),
'#options' => $am__preset,
'#default_value' => ($ss__imagecase_size) ? $ss__imagecase_size : 0,
'#description' => t("Select the preset to set the size of the CTA image.
Alternatively, you can set custom image size below and leave this field."),
);
$ss__custom_size = t("This value will be ignored if a preset is selected above.");
}
$form['custome_cta_size'] = array(
'#type' => 'textfield',
'#title' => t("image size"),
'#description' => t("Define your custom size of the CTA image.
The size should be in wxh or wXh format.") ." ". $ss__custom_size,
'#default_value' => ($ss__size) ? $ss__size : '50X50',
'#size' => 20,
'#maxlength' => 8,
);
$form['cta_weight'] = array(
'#type' => 'textfield',
'#title' => t("Weight"),
'#size' => 10,
'#attributes' => array('class' => 'cta-weight'),
'#required' => TRUE,
'#default_value' => ($sn_weight) ? $sn_weight : 0,
'#maxlength' => 4,
);
$form['#validate'] = array('drupald_navigation_cta_validate');
return $form;
}
/**
*
* @param $ss__name
* @return unknown_type
*
* @author Drupal Developer <http://twitter.com/DrupalD>
*/
function get_cta($ss__name) {
if ($ss__name) {
$r__result = db_query("SELECT title, nid FROM {node} WHERE type = 'drupaldcta'
AND LOWER(title) LIKE LOWER('%s%%') AND status = 1", $ss__name);
while ($om__result = db_fetch_object($r__result)) {
$ss__value = $om__result->title ." - ". t("node") .": ". $om__result->nid;
$am__data[$ss__value] = check_plain($om__result->title) ." - ". t("node")
.": ". $om__result->nid;
}
if (empty($am__data)) {
return drupal_json("");
}
else {
return drupal_json($am__data);
}
}
}
/**
*
* @param $form
* @param $form_state
* @return unknown_type
*/
function drupald_navigation_cta_submit($form, &$form_state) {
$an__nid = preg_split("/(node:)/", $form_state['values']['nodes']);
$ss__size = $form_state['values']['cta_size'] ?
$form_state['values']['cta_size'] : $form_state['values']['custome_cta_size'];
db_query("INSERT INTO {drupald_navigation} VALUES(drupald_id, %d, %d, '%s', '%s',
'%s')", $an__nid[1], $form_state['values']['menus'], $ss__size,
$form_state['values']['cta_weight'], 1);
drupal_set_message(t("CTA has been saved."));
}
/**
*
* Enter description here...
* @param $form
* @param $form_state
* @return unknown_type
*/
function drupald_navigation_cta_update($form, &$form_state) {
$sn__drupald_id = $form_state['values']['drupald_id'];
$ss__size = $form_state['values']['cta_size'] ?
$form_state['values']['cta_size'] : $form_state['values']['custome_cta_size'];
db_query("UPDATE {drupald_navigation} SET mlid = %d, image_size = '%s',
weight = '%s' WHERE drupald_id = %d", $form_state['values']['menus'],
$ss__size, $form_state['values']['cta_weight'], $sn__drupald_id);
drupal_set_message(t("CTA has been update."));
}
/**
*
* @param $form
* @param $form_state
* @return unknown_type
*/
function drupald_navigation_cta_validate($form, &$form_state) {
$an__nid = preg_split("/(node:)/", $form_state['values']['nodes']);
if (!$form_state['values']['menus']) {
form_set_error('menus', t("Menu is required"));
}
$sn__menu_id = db_result(db_query("SELECT mlid FROM {drupald_navigation} WHERE nid = %d",
$an__nid[1]));
if ($sn__menu_id == $form_state['values']['menus'] &&
$form_state['values']['menus'] != 0) {
form_set_error('nodes', t("This node is already assigned to the menu.
Selecte a different menu or node."));
}
if ($form_state['values']['cta_size'] == 0 &&
$form_state['values']['custome_cta_size'] == NULL) {
form_set_error('custome_cta_size', t("Image size is required"));
}
}
/**
*
* Enter description here...
* @param $ss__menu_id
* @return unknown_type
*/
function get_drupald_cta_menu($ss__menu_id) {
if ($ss__menu_id) {
$r__result = db_query_range("SELECT cta.nid, cta.weight, cta.image_size,
drupald.field_drupaldcta_image_fid, drupald.field_drupaldcta_image_data,
drupald.field_drupaldcta_url_value url, n.title, nr.body, f.filepath FROM {drupald_navigation} cta
INNER JOIN {content_type_drupaldcta} drupald USING ( nid ) INNER JOIN {files} f
ON drupald.field_drupaldcta_image_fid = f.fid INNER JOIN {node} n USING ( nid )
INNER JOIN {node_revisions} nr USING ( nid ) WHERE cta.mlid = %d AND
cta.status = 1 AND n.status = 1 ORDER BY cta.weight", $ss__menu_id, 0, 3);
$sn__vid = db_result(db_query("SELECT vid FROM {vocabulary} WHERE name = 'drupald-vocabulary'"));
while ($om__result = db_fetch_object($r__result)) {
$sm__term = db_result(db_query("SELECT t.name FROM {term_data} t INNER JOIN {term_node} r ON r.tid = t.tid
WHERE t.vid = %d AND r.vid = %d", $sn__vid, $om__result->nid));
$pattern = array('x', 'X');
$am__image_data = unserialize($om__result->field_drupaldcta_image_data);
list($width, $height) = preg_split("/(x|X)/", $om__result->image_size);
$option = array('html' => TRUE);
$ss__body_link = l("<strong>". $sm__term ."</strong><span>".strip_tags($om__result->body) ."</span>", $om__result->url, $option);
$am__ctal_link['title'][] = $om__result->title;
$am__ctal_link['body'][] = $ss__body_link;
$am__ctal_link['image'][] = $om__result->filepath;;
/*if (!$height) {
$ss__preset = db_result(db_query("SELECT presetname FROM
{imagecache_preset} WHERE presetid= %d", $width));
$ss__image = theme('imagecache', $ss__preset, $om__result->filepath,
$am__image_data['alt'], $am__image_data['title']);
}
else {
$am__size = array('height' => $height, 'width' => $width);
$ss__image = theme('image', $om__result->filepath,
$am__image_data['alt'], $am__image_data['title'], $am__size, FALSE);
}
$ss__body_link = l(strip_tags($om__result->body), $om__result->url);
// $ss__cta_link = l($ss__image, $om__result->url, array('html' => TRUE));
$am__ctal_link['title'][] = $om__result->title;
$am__ctal_link['body'][] = $ss__body_link;
$am__ctal_link['image'][] = $ss__image;*/
}
return $am__ctal_link;
}
}
/**
*
* Enter description here...
* @return unknown_type
*/
function get_stored_cta() {
$header = array(
t("Node"),
t("Menu"),
t("Image size"),
t("Status"),
t("Weight"),
array('data' => t("Operation"), 'colspan' => 2),
);
$ss__destination = drupal_get_destination();
$r__result = db_query("SELECT * FROM {drupald_navigation} ORDER BY weight asc");
while ($om__result = db_fetch_object($r__result)) {
$ss__node_title = db_result(db_query("SELECT title FROM {node} WHERE
nid = %d", $om__result->nid));
$ss__menu_name = db_result(db_query("SELECT link_title FROM {menu_links} WHERE
mlid = %d", $om__result->mlid));
list($width, $height) = preg_split("/(x|X)/", $om__result->image_size);
if (!$height) {
$ss__preset = db_result(db_query("SELECT presetname FROM
{imagecache_preset} WHERE presetid= %d", $width));
$ss__size = l($ss__preset, 'admin/build/imagecache/'. $width);
}
else {
$ss__size = $om__result->image_size;
}
$am__weight['cta_weight_'. $om__result->drupald_id] = array(
'#type' => 'textfield',
'#size' => 5,
'#default_value' => $om__result->weight,
'#attributes' => array('class' => 'cta-weight'),
);
$ss__status = ($om__result->status) ? t("Enabled") : t("Disabled");
$ss__disabled = (!$om__result->status) ? "menu-disabled" : NULL;
$row[] = array('data' => array (
l($ss__node_title, "node/". $om__result->nid),
$ss__menu_name,
$ss__size,
l($ss__status, 'admin/build/drupald-navigation/cta/'. $om__result->drupald_id
."/status", array('attributes' => array('title' => t("Click to toggle")),
'query' => $ss__destination)),
drupal_render(form_builder(NULL, $am__weight, $form_state)),
l(t("edit"), 'admin/build/drupald-navigation/cta/'. $om__result->drupald_id ."/edit"
, array('query' => $ss__destination)),
l(t("delete"), 'admin/build/drupald-navigation/cta/'. $om__result->drupald_id ."/delete"
, array('query' => $ss__destination)),
),
'class' => "draggable ". $ss__disabled,
);
unset($am__weight);
}
$am__attributes = array('id' => 'cta-menu-added');
drupal_add_tabledrag('cta-menu-added', 'order', 'sibling', 'cta-weight');
return (!empty($row) ? theme('table', $header, $row, $am__attributes) : NULL);
}
/**
*
* Enter description here...
* @param $nid
* @return unknown_type
*/
function drupald_get_node_title($nid) {
return db_result(db_query("SELECT title from {node} WHERE nid = %d", $nid));
}
/**
*
* Enter description here...
* @return unknown_type
*/
function drupald_navigation_list() {
$form = array();
$am__cta = get_stored_cta();
$form['cta_added'] = array(
'#type' => 'item',
'#value' => get_stored_cta(),
'#weight' => -10,
);
if (!empty($am__cta)) {
$form['cta_update'] = array(
'#type' => 'submit',
'#submit' => array('drupald_cta_rearrange_update'),
'#value' => t("Save configuration"),
'#weight' => 50,
);
}
return $form;
}
/**
*
* @param $form
* @param $form_state
* @return unknown_type
*/
function drupald_cta_rearrange_update($form, $form_state) {
$am__post_key = array_keys($form_state['clicked_button']['#post']);
$am__cta_weight = preg_grep('/^(cta_weight_)/', $am__post_key);
for ($i = 0; $i < count($am__cta_weight); $i++) {
$am__drupald_id = preg_split('/^(cta_weight_)/', $am__cta_weight[$i], -1,
PREG_SPLIT_NO_EMPTY);
if ($am__drupald_id[0]) {
db_query("UPDATE {drupald_navigation} SET weight = %d WHERE drupald_id = %d",
$form_state['clicked_button']['#post'][$am__cta_weight[$i]], $am__drupald_id[0]);
}
}
drupal_set_message(t("Configuration has been saved."));
}
function drupald_navigation_block($op = 'list', $delta = 0, $edit = array()){
switch ($op) {
case 'list':
$blocks[0] = array('info' => t("WorldWide custom filter block"),
'weight' => 0);
return $blocks;
case 'view':
$block = array();
switch ($delta) {
case 0:
$block = array('subject' => t("World wide"),
'content' => drupal_get_form('world_block_filter'));
break;
}
return $block;
}
}
/**
*
* @return unknown_type
*/
function world_block_filter() {
$form = array();
$sn__vid = db_result(db_query("SELECT vid FROM {vocabulary} WHERE name = 'Worldwide'"));
$am__term_tree = taxonomy_get_tree($sn__vid);
$form['#method'] = 'GET';
$form['#action'] = url('world-wide');
$am__node = array();
foreach ($am__term_tree as $om__term) {
$am__node = _get_worldwide_node($om__term->tid);
$am__node[0] = $om__term->name;
ksort($am__node);
$form['worldwide_'. $om__term->tid] = array(
'#type' => 'select',
'#options' => $am__node,
);
}
return $form;
}
/**
*
* @param $sn__tid
* @return unknown_type
*/
function _get_worldwide_node($sn__tid) {
$form_build_id = $_POST['form_build_id'];
$form_id = $_POST['form_id'];
$form_state = array('storage' => NULL, 'submitted' => FALSE);
$r__node = taxonomy_select_nodes(array($sn__tid));
while ($om__node = db_fetch_object($r__node)) {
$am__node[$om__node->nid] = $om__node->title;
}
return $am__node;
}
function drupald_navigation_form_world_block_filter_alter(&$form, $form_state) {
foreach ($form as $key => $field) {
if ($field['#type'] == 'select') {
$form[$key]['#attributes'] = array('onselect' => 'this.form.submit()');
}
}
}
?>The following code should be written in template.php in your theme directory
<?php
/**
* Override or insert variables into the block templates.
*
* @param $vars
* An array of variables to pass to the theme template.
* @param $hook
* The name of the template being rendered ("block" in this case.)
* @author Drupal Developer <http://twitter.com/DrupalD>
*/
/* -- Delete this line if you want to use this function
function STARTERKIT_preprocess_block(&$vars, $hook) {
$vars['sample_variable'] = t('Lorem ipsum.');
}
*/
function phptemplate_nice_menu_build($menu) {
$menu_count = 0;
$output = '';
foreach ($menu as $menu_item) {
$mlid = $menu_item['link']['mlid'];
// Check to see if it is a visible menu item.
if ($menu_item['link']['hidden'] == 0) {
// Build class name based on menu path
// e.g. to give each menu item individual style.
// Strip funny symbols.
$clean_path = str_replace(array('http://', '<', '>', '&', '=', '?', ':'), '', $menu_item['link']['href']);
// Convert slashes to dashes.
$clean_path = str_replace('/', '-', $clean_path);
$path_class = 'menu-path-'. $clean_path;
// If it has children build a nice little tree under it.
if ((!empty($menu_item['link']['has_children'])) && (!empty($menu_item['below']))) {
// Keep passing children into the function 'til we get them all.
$children = theme('nice_menu_build', $menu_item['below']);
// Set the class to parent only of children are displayed.
$parent_class = $children ? 'menuparent ' : '';
$menu_item['link']['title'] = "<span>" .$menu_item['link']['title']
."<em> </em></span><strong> </strong>";
$menu_item['link']['localized_options']['html'] = TRUE;
$am__links = array('Disciplines', 'Veterinary', 'Youth', 'Development');
if ($menu_item['link']['menu_name'] == 'menu-main-navigation') {
$ss__smal_class = "";
if (in_array($menu_item['link']['link_title'], $am__links)) {
$ss__smal_class = " drop-purple-wrapper";
}
$menu_count++;
$ss__active = "";
$ss__active = (arg(0) == $menu_item['link']['link_path'] ? " active" : "");
$menu_item['link']['localized_options']['attributes']['class'] = "drop";
$ss__extra_class = $menu_item['link']['weight'] == -50 ? 'left ' : NULL;
if ($menu_count == 1) {
$output .= '<li id="menu-'. $mlid .'" class=" sec-menu-nav '. $ss__extra_class
. $parent_class . $path_class . $ss__active . $ss__smal_class .'">'. theme('menu_item_link', $menu_item['link']);
}
elseif ($menu_count == 6) {
$output .= '<li id="menu-'. $mlid .'" class=" last-menu-nav '. $ss__extra_class
. $parent_class . $path_class . $ss__active . $ss__smal_class .'">'. theme('menu_item_link', $menu_item['link']);
}
else {
$output .= '<li id="menu-'. $mlid .'" class="'. $ss__extra_class
. $parent_class . $path_class . $ss__active . $ss__smal_class .'">'. theme('menu_item_link', $menu_item['link']);
}
}
else {
$output .= '<li id="menu-'. $mlid .'" class="'. $parent_class .
$path_class .'">'. theme('menu_item_link', $menu_item['link']);
}
// Build the child UL only if children are displayed for the user.
if ($children && ($menu_item['link']['menu_name'] != 'menu-main-navigation'
&& $menu_item['link']['menu_name'] != 'menu-utility' &&
$menu_item['link']['menu_name'] != 'menu-fei-footer-menu')) {
$output .= '<ul>';
$output .= $children;
$output .= "</ul>\n";
}
if ($menu_item['link']['menu_name'] == 'menu-main-navigation') {
//Get CTAs
$i = 1;
$j = 1;
//$menu_count++;
if (module_exists('fei_navigation')) {
$am__cta_menu = get_fei_cta_menu($menu_item['link']['mlid']);
}
$am__links = array('Disciplines', 'Veterinary', 'Youth', 'Development');
$b__small = FALSE;
if(in_array($menu_item['link']['link_title'], $am__links)) {
$b__small = TRUE;
$output .= "<div class=\"drop-purple\"><div class=\"drop-purple-t\"></div>";
$output .= "<div class=\"drop-purple-c\">";
$output .= "<ul>";
}
else {
$output .= "<div class=\"drop-box\"><div class=\"drop-top\"></div>";
$output .= "<div class=\"drop-center\">";
$output .= "<div class=\"box\"><ul>";
}
$sn__children = ceil(count($menu_item['below'])/3);
foreach ($menu_item['below'] as $menu_child) {
if (!$menu_child['link']['hidden']) {
$output .= "<li class='menu-". $menu_child['link']['mlid'] ."'>".
l($menu_child['link']['link_title'],
$menu_child['link']['href']) ."</li>";
if ((!empty($am__cta_menu['title'])) && ($j == $sn__children || $i == count($menu_item['below']))) {
$j = 0;
$output .= "<li style='border:none;'><strong class=\"heading\">".
$am__cta_menu['title'][0] ."</strong> <div class='image-box' style='background:url("."\/".
$am__cta_menu['image'][0] . ") no-repeat;'>". $am__cta_menu['body'][0] ."</div></li>";
array_shift($am__cta_menu['title']);
array_shift($am__cta_menu['image']);
array_shift($am__cta_menu['body']);
}
if (($i % $sn__children == 0) && $i != 1) {
if (!$b__small) {
$output .= "</ul></div><div class=\"box\"><ul>";
}
}
$i++;
$j++;
}
else {
$i++;
$j++;
}
unset($menu_child);
}
unset($menu_child, $menu_item['below']);
$output .= ($b__small ? "</ul></div><div class=\"drop-purple-b\"></div></div>" : "</ul></div></div><div class=\"drop-bottom\"></div></div>");
}
else if ($menu_item['link']['menu_name'] == 'menu-utility') {
$output .= "<div class=\"drop\"><div class=\"drop-t\"></div>";
$output .= "<div class=\"drop-c\">";
$output .= "<ul>";
foreach ($menu_item['below'] as $menu_child) {
$output .= "<li>". l($menu_child['link']['link_title'],
$menu_child['link']['href']) ."</li>";
}
$output .= "</ul>";
$output .= "</div><div class=\"drop-b\"></div></div>";
}
else if ($menu_item['link']['menu_name'] == 'menu-fei-footer-menu') {
foreach ($menu_item['below'] as $menu_child) {
$count = $count + 1;
}
$cnt = -(($count * 34)+94);
$count = 0;
//$output .= "<div class=\"drop\" ><div class=\"drop-t\"></div>";
$output .= "<div class=\"drop\" style=\"top: ". $cnt ."px !important;\"><div class=\"drop-b\"></div>";
$output .= "<div class=\"drop-c\">";
$output .= "<ul>";
foreach ($menu_item['below'] as $menu_child) {
$output .= "<li>". l($menu_child['link']['link_title'],
$menu_child['link']['href']) ."</li>";
}
$output .= "</ul>";
$output .= "</div><div class=\"drop-t\"></div></div>";
}
$output .= "</li>\n";
}
else {
if ($menu_item['link']['link_path'] != 'search' && empty($menu_item['below'])) {
$path_class .= " no-drop";
}
else if ($menu_item['link']['link_path'] == 'search') {
$path_class .= " no-drop last";
}
$menu_item['link']['title'] = "<span>" .$menu_item['link']['title']
."</span><strong> </strong>";
$menu_item['link']['localized_options']['html'] = TRUE;
$output .= '<li id="menu-'. $mlid .'" class="'. $path_class .'">'.
theme('menu_item_link', $menu_item['link']) .'</li>'."\n";
}
}
}
return $output;
}
?> (3 votes)
- Login or register to post comments
- 5460 reads
-
Your feedback


Recent comments
- I have contributed a module
20 weeks 6 days ago - Improved Image menu
39 weeks 3 days ago - Great code!
41 weeks 1 day ago - Code Search is ready
50 weeks 4 days ago - I would love to see an
1 year 2 weeks ago - Thank you very much for your
1 year 3 weeks ago - Commented code
1 year 3 weeks ago - We are glad to know that the
1 year 3 weeks ago - Enhancements to codes
1 year 3 weeks ago - We have developed a module
1 year 4 weeks ago



Comments
We have improved the Image menu code and also included the function to be written in template.php file in theme directory.
[url=http://twitter.com/DrupalD][i]Drupa Developer - A Comprehensive Guild to Drupal Developersl[/i][/url]
To make the image menu work properly, you have to create a function in your tempate.php file to inject images created using the image menu interface. Rest will be taken care by the code itself.
Yes, that's true.
Thanks for drawing attention.
[url=http://twitter.com/DrupalD][i]Drupa Developer - A Comprehensive Guild to Drupal Developersl[/i][/url]