0

I use Drupal 7 with Bootstrap Theme. I have many blocks placed on different nodes and HTML generated is as follows:

<div class="region region-content">
  <section id="block-system-main" class="block block-system clearfix col-md-12">
    <div id="node-21" class="node node-pagina clearfix">  
      <div class="content">
        [...]
      </div>
    </div>
  </section> <!-- /.block -->

  <section id="block-block-13" class="block block-block contextual-links-region clearfix col-md-4">
    [...]
  </section> <!-- /.block -->

  <section id="block-block-12" class="block block-views contextual-links-region clearfix col-md-6">
    [...]
  </section> <!-- /.block -->

  <section id="block-block-15" class="block block-block contextual-links-region clearfix col-md-12">
    [...]
  </section> <!-- /.block -->

  <section id="block-block-14" class="block block-block contextual-links-region clearfix col-md-12">
    [...]
  </section> <!-- /.block -->
</div>

I want to change that HTML for put some <div class="container"> to enclosing some <sections>

Example:

<div class="container">
    <section id="block-block-13" class="block block-block contextual-links-region clearfix col-md-4">
      [...]
    </section> <!-- /.block -->

    <section id="block-block-12" class="block block-views contextual-links-region clearfix col-md-6">
      [...]
    </section> <!-- /.block -->
  </div>

1 Answer 1

2

Short answer: Place a customized template named node--[nid].tpl.php or page--node--[nid].tpl.php in your themes template folder. ([nid] = id of specific node).

Long answer: If you didn't done yet, you should first create a Bootstrap subtheme for your modifications. Then copy either node.tpl.php or page.tpl.php from the Bootstarp theme inside your subtheme folder. Rename the file to either node--[nid].tpl.php or page--node--[nid].tpl.php (Replace [nid] with the node id of the specific node) and customize the file to your liking. Lastly clear the cache at /admin/config/development/performance

For more/other template examples have a look at Drupal 7 Template (Theme Hook) Suggestions

EDIT: To control specific blocks for a specific page, I'd create a dedicated region inside your subtheme's .info-file and in your page.tpl.php / page--node--[nid].tpl.php. And place the blocks inside those regions.

2
  • 1
    For page specific blocks you can also just restrict which pages that block is shown on instead of creating a new region for it. Though I do like that idea and it likely has its applications Sep 9, 2015 at 22:09
  • If it is just to control where the block is shown you're absolutely right. But in the question it seemed like the OP was looking for a way to place/group blocks depending on the page/node.
    – phils
    Sep 11, 2015 at 13:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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