How do I include a class in a link inserted in an entitiy's link area? I want to insert a link to a ctools modal popup with a custom style (class) into the link area at the bottom of an entity (e.g. a node).  I do this using hook_entity_view_alter.  This is how the relevant part of my code looks like:

/**
 * Implements hook_entity_view_alter().
 */
function mymodule_entity_view_alter(&amp;$build) {
  // Set up ctools etc. to use modal omitted for brevity.
  $build['links']['popup']['#links']['mylink']['title'] = 'show popup';
  $build['links']['popup']['#links']['mylink']['href'] = 'mymodule/nojs/modals';
  $build['links']['popup']['#links']['mylink']['html'] = TRUE;
 }


The code shown above inserts the following link in the right place:

&lt;a href="/mymodule/nojs/modals"&gt;show popup&lt;/a&gt;


However, this leaves out the class required to give the modal a custom style.  This what I really want to have this link look like:

&lt;a href="/mymodule/nojs/modals" class="ctools-use-modal ctools-modal-mymodule-style"&gt;show popup&lt;/a&gt;


Question: How do I get class="ctools-use-modal ctools-modal-mymodule-style" included in this link?
You can add the html attributes using the attributes key which accepts an array of attributes, and add classes using the class key, which also accepts an array of classes.

/**
 * Implements hook_entity_view_alter().
 */
function mymodule_entity_view_alter(&amp;$build) {
  // Set up ctools etc. to use modal omitted for brevity.
  $build['links']['popup']['#links']['mylink'] = array(
    'title' =&gt; 'show popup',
    'href' =&gt; 'mymodule/nojs/modals',
    'html' =&gt; TRUE,
    'attributes' =&gt; array(
      'class' =&gt; array(
        'ctools-use-modal', 
        'ctools-modal-mymodule-style',
      ),
    ),
  );
}


More information about available keys, refer to theme_links() function in Drupal API.