I need to add some custom markup inside the first list-item of the main-menu as you can see here:
<div id="block-system-main-menu"> <div class="block-inner clearfix"> <div class="content clearfix"> <ul class="menu"> <li class="first leaf"><a href="/de/t1">Item 1</a> <div class="my-custom-markup> … … </div> </li> <li class="leaf"><a href="/de/t2">Item 2</a></li> <li class="last leaf"><a href="/de/t3">Item 2</a></li> </ul> </div> </div> </div>
With the following code, I can insert the markup:
function mytheme_preprocess_menu_link(&$ variables) { $ variables['element']['#below']['#markup'] = ' <div class="my-custom-markup">...</div>'; }
But this code adds the markup to every list-item, not just the first one. Do I use the appropriate function and how can I add the markup only at the first item?