Wednesday 13 July 2016

How to add Mobile Responsive Preview Links to Administration Menu in Drupal 7?

Need to enable Responsive Preview module and use hook_admin_menu_output_build() as below:
/**
 * Add responsive preview links to the Admin Menu.
 */
function custom_admin_menu_output_build(&$content){
    $content['responsive_preview'] = array(
        'device_options' => array(
                '#theme' => 'item_list',
                '#items' => responsive_preview_get_devices_list(),
                '#attributes' => array(
                    'id' => 'responsive-preview-navbar-tab',
                    'class' => array('responsive-preview-options'),
                ),
            ),
        '#wrapper_attributes' => array(
            'class' => array('navbar-tab-responsive-preview'), // Class Name is important as Responsive Preview JS will work based on the class name
        ),
        '#weight' => 200,
        '#access' => responsive_preview_access(),
    );
}
And, add Responsive Preview library in hook_init() function
function custom_init() {
    drupal_add_library('responsive_preview', 'responsive-preview');
}

No comments:

Post a Comment

Your comment is so valuable as it would help me in my growth of knowledge.