Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The new HTML5 data-* attribute can be specified on any element but I noticed that you have already an API file in your module folder to add additional attributes to menu links.
I wanted to add the following code but was only able to hack the modules function menu_attributes_menu_attribute_info
// Add a data-toggle attribute.
$info['data-toggle'] = array(
'label' => t('Data Toggle'),
'description' => t('Specifies a HTML5 Data- attribute. This is a data-toggle attribute for the Twitter Bootstrap dropdown menu. '),
'form' => array(
'#maxlength' => 20,
'#size' => 20,
),
);
How do I add additional attributes? By including the API code in template.php or do I have to copy the whole function or I hack the modules function?
Also I was hoping you might consider expanding the attributes to include some generic data-* options in the module.
Comments
Comment #1
osopolarThis already could be done implementing hook_menu_attribute_info() in your custom module. See menu_attributes.api.php for an example.
Comment #1.0
osopolarposted wrong code comment target instead of toggle