<?phpfunction THEMENAME_links__system_main_menu($variables){$links=$variables['links'];$attributes=$variables['attributes'];$heading=$variables['heading'];global$language_url;$output='';if(count($links)>0){$output='';// Treat the heading first if it is present to prepend it to the// list of links.if(!empty($heading)){if(is_string($heading)){// Prepare the array that will be used when the passed heading// is a string.$heading=array('text'=>$heading,// Set the default level of the heading.'level'=>'h2',);}$output.='<'.$heading['level'];if(!empty($heading['class'])){$output.= drupal_attributes(array('class'=>$heading['class']));}$output.='>'. check_plain($heading['text']).'</'.$heading['level'].'>';}$output.='<ul'. drupal_attributes($attributes).'>';$num_links=count($links);$i=1;foreach($linksas$key=>$link){$class=array($key);// Add first, last and active classes to the list of links to help out themers.if($i==1){$class[]='first';}if($i==$num_links){$class[]='last';}if(isset($link['href'])&&($link['href']==$_GET['q']||($link['href']=='<front>'&& drupal_is_front_page()))&&(empty($link['language'])||$link['language']->language==$language_url->language)){$class[]='active';}$output.='<li'. drupal_attributes(array('class'=>$class)).'>';if(isset($link['href'])){// Pass in $link as $options, they share the same keys.$output.= l($link['title'],$link['href'],$link);}elseif(!empty($link['title'])){// Some links are actually not links, but we wrap these in <span> for adding title and class attributes.if(empty($link['html'])){$link['title']= check_plain($link['title']);}$span_attributes='';if(isset($link['attributes'])){$span_attributes= drupal_attributes($link['attributes']);}$output.='<span'.$span_attributes.'>'.$link['title'].'</span>';}$i++;$output.="</li>\n";}$output.='</ul>';}return$output;}?>
5 个回答
这个估计需要在template.php 重写
分头诗人Lv 17
诗人,代码加入template.php后页面 没有变化,那我在page.tpl.php里该怎么写呢?只琢磨出[attributes]数组是控制<ul>标签容器的
<?php print theme('links__system_main_menu', array(
'links' => $main_menu,
'attributes' => array( //define the css of '<ul>'
//'id' => 'main-menu-links',
//'class' => array('links'),
),
'heading' => array(
//'text' => t('Main menu'),
'level' => 'h2',
'class' => array('element-invisible'),
),
)); ?>
春田镇三眼鱼Lv 9
诗人,<span>标签没有在页面代码里出现过
春田镇三眼鱼Lv 9
按理说
是遍历$link(应该是我在后台菜单加的链接吧?)的时候,每次都输出一个
但是我把这行代码删除了对菜单显示没有影响.......
春田镇三眼鱼Lv 9
诗人,我找到解决办法了,47行改为
春田镇三眼鱼Lv 9