0

I'm trying to display a block on a left side bar with few links. I've created a block and it shows up with the links but NO CSS applied:

<div class="vertical-tabs">
    <ul class="ul.vertical-tabs-list">
        <li>
            <a href="/">Home</a>
        </li>
        <li>
            <a href="itemInfo">Site Info</a>
        </li>
        <li>
            <a href="jobs">Career</a>
        </li>
        <li>
            <a href="aboutus">About Us</a>
        </li>
    </ul>
</div>

When I check the elements in UI, it doesn't show the vertical-tabs class being applied.

I'm not looking for any custom form. I need to know how the CSS should be applied in this case.

Thanks.

  • example: jsfiddle.net/0c4ap3kh – No Sssweat Apr 12 '16 at 2:39
  • You may have a text-format applied that strips out certain html elements. – Volker Apr 12 '16 at 11:49
  • Are you creating the block in a module, or from the user interface? – kiamlaluno Apr 12 '16 at 12:24
  • Creating a block from the interface. There is no custom form/code. – Vish Apr 12 '16 at 16:28
2

There's a template hook for this: template_preprocess_block

Use $variables['classes_array'] to add classes to the block.

|improve this answer|||||
  • To add the template hook, I should have custom code written. That's not the case here. I'm using a user interface to create a new block. So I'm not sure on how to add this hook in interface. – Vish Apr 12 '16 at 16:29
0

Try this for custom block

function my_module_block_view($delta = '')
{
  if($delta == 'my_module_delta')
  {
    drupal_add_js('path/to/file.js');
    drupal_add_css('path/to/file.css');
    $block = array
    (
      'subject' => t('My block title'),
      'content' => '<p>' . t('This is some text that will go in the block.') . '</p>',
    );
    return $block;
  }
}
|improve this answer|||||
0

Try this

$block['content']['#attached']['css'][] = drupal_get_path('module','mymodule') . '/mymodule.css';
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.