robdecker
11/24/2014 - 9:24 PM

Drupal 7: Block content in render array.

Drupal 7: Block content in render array.

<?php

function my_module_share_sidebar() {
  return array(
    '#theme' => 'item_list',
    '#type' => 'ul',
    '#attributes' => array(
      'class' => array('share-this'),
    ),
    '#attached' => array(
      'js' => array(
        array(
          'data' => 'var switchTo5x=true;',
          'type' => 'inline',
        ),
        array(
          'data' => 'http://w.sharethis.com/button/buttons.js',
          'type' => 'external',
        ),
        array(
          'data' => 'stLight.options({doNotHash: false, doNotCopy: false, hashAddressBar: false});',
          'type' => 'inline',
        ),
      ),
    ),
    '#items' => array(
      array(
        'data' => '<span class="st_facebook_large" displayText="Facebook"></span>',
      ),
      array(
        'data' => '<span class="st_twitter_large" displayText="Tweet"></span>',
      ),
      array(
        'data' => '<span class="st_googleplus_large" displayText="Google +"></span>',
      ),
      array(
        'data' => '<span class="st_pinterest_large" displayText="Pinterest"></span>',
      ),
      array(
        'data' => '<span class="st_sharethis_large" displayText="ShareThis"></span>',
      ),
    ),
  );
}