0

While views does a great job of placing blocks and content on a page, I am trying to make my website responsive. It is true that the blocks are responsive. I am just trying to make it so that the blocks take up a percentage of the screen rather than go below another block when the screen shrinks. I found a way to do this using CSS, but I would rather use standard Drupal methods so that my users can edit content. There is a nice module that lets you define a class on each block, and I am using it. I am just wondering if there is something similar so I can define a wrapper of several blocks. I am using Drupal 7.

  • Did you try drupal.org/project/layout – vijaycs85 Aug 4 '14 at 23:59
  • I'm note quite clear on what you wish to accomplish. Blocks per se have nothing to do with responsiveness. That is completely up to your theme. You need to use a responsive theme (Omega, Zen, etc.) and then you define responsive areas for your blocks to go in if what is present in the base theme regions is not to your liking. You can do this in CSS or you can use the grid system that is integrated with the theme. You can also swap out one grid system for another if you please. Some themes come with predefined classes for responsiveness, such as Bootstrap which is really easy to use. – J. Reynolds Aug 5 '14 at 9:22
  • I'm using my own theme. I have to use it and not one of the themes that are already out there. I know of a method to make blocks responsive if I can have a wrapper class/id around my blocks. Thus, I need to know if it is possible to add a wrapper class/id to a group of blocks. – Guybrush Threepwood Aug 5 '14 at 15:45
  • @vijaycs85, this looks cool, but I don't want to use something that is in alpha production. – Guybrush Threepwood Aug 5 '14 at 15:51
  • Block are already wrapped by a region (content, sidebar, footer). If the region is not present to your liking add a custom region. And if your blocks will share a region with some other content, then split that region into two regions under a div parent and wrap with divs and fixed classes to your liking. It's all done in the theme's page.tpl.php and info file. In addition you could add more dynamic classes to regions via template_preprocess_region() function in theme's template file. – J. Reynolds Aug 5 '14 at 16:25
0

If I understand you correctly, you can use the Theme Developer module to inspect the block itself. You will be able to take the default block template out of the main theme directory, rename it accordingly, and then edit it to have your class. This is not the best way to achieve this result, but it will work. Make sure to disable the module when you are done using it.

In addition to that, the block themselves will have their own independent ids "#block-block-17". A little more painful to work with, but if you don't have that many it could be another solution for you.

  • Thanks for the answer! I eventually went with Panels and Panelizer. In the situation of your last paragraph, the Block Class Module is really good at giving a specific class name to each block. This module can be found here: drupal.org/project/block_class – Guybrush Threepwood Aug 28 '14 at 23:33
  • ahh! I didn't know that existed. Thanks for the heads up! – e.shell Aug 28 '14 at 23:35

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.