[英]Adding html class/ID to hook_menu generated link
I'm trying to add a class or ID to a link generated from my hook_menu code included below: 我正在尝试将类或ID添加到通过以下我的hook_menu代码生成的链接中:
<?php
function mymodule_menu() {
$items['mypage_redirect'] = array(
'page callback' => 'mypage_redirect_callback',
'type' => MENU_CALLBACK,
'access arguments' => array("access content"),
'title' => 'My module generated page',
'options' => array(
'attributes' => array(
'class' => array(
'test-class'
)
)
),
);
return $items;
}
All I'm trying to accomplish a simple link with a class of 'test-class' so I can style it but the instructions I followed to get the above code has not worked. 我正在尝试完成与“测试类”类的简单链接,因此可以为它设置样式,但是为获得上述代码而遵循的说明无效。
function commons_menu() {
$items = array();
$items['test'] = array(
'title' => t("test"),
'access callback' => TRUE,
'type' => MENU_NORMAL_ITEM,
'options' => array(
'attributes' => array(
'class' => 'test-menu'
)
)
);
return $items;
}
Have cheked other forums too!!.. the attibutes doesn't work with MENU_LOCAL_ACTION
or MENU_LOCAL_TASK
Your code looks fine.. did you try clearing cache after the changes? 也MENU_LOCAL_ACTION
其他论坛!!。 MENU_LOCAL_ACTION
无法与MENU_LOCAL_ACTION
或MENU_LOCAL_TASK
您的代码看起来还不错。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.