I am trying to convert html to Drupal 7 theme.

function theme_menu_tree($variables){ return '<ul class="my-class-1">' . $variables['tree'] . '</ul>'; }

simply returns the entire menu how to make it like following <ul class="my-class-1"> <li class="dropdown">Item <ul class="my-class-2"> <li>Link1</li> <li>Link2</li> </ul> </li> </ul>


Use theme_item_list function for it, see the below code

$title = 'Title';
$type = 'ol';
$items = array(
$items[] = array(
  'data' => 'something',
  'class' => array('dummy'=>'category'),
  'children' => array('1.1','1.2',array('data'=>'1.3','class' => array('dummy'=>'category'),'children'=>array('1.3.1','1.3.2')))
$attributes = array('class' => array('test-class', 'demo-class'));

print theme_item_list(array(
  'items' => $items,
  'title' => $title,
  'type' => $type,
  'attributes' => $attributes

This will give you following HTML output:

<div class="item-list"><h3>Title</h3>
  <ol class="test-class demo-class">
    <li class="first">one</li>
    <li class="category last">something
      <div class="item-list">
        <ol class="category">
          <li class="first">1.1</li>
          <li class="category last">1.3
            <div class="item-list">
              <ol class="category">
                <li class="first">1.3.1</li>
                <li class="last">1.3.2</li>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.