2

I created a custom block that I want to include in my template file. But I don't want to include using block id. Is there any way to do it?

I enabled the box module so a machine name is added with each block. I want to add using machine name.

1

If you want to export the block as part of a Feature (as per your comment above), then you can use the Features Extra module.

Features Extra provides faux exportables (via Features) of several site-building components.

[...]

Block

To export a block, install FE Block, edit your block, give it a "machine name," export it with Features. You can export block settings (region settings, visibility settings, ...) of any block, and the content of blocks created with the Block module from Drupal core. The D7 version supports the Block Class, i18n block and Block Cache Alter modules.

  • Yes and get the block id from database using machine name. Now the id can be different. Thanks. – Sumit Madan Sep 6 '13 at 9:31
1

I dont think there are any machine names associated with a block. At least didnt saw it in the database. And by the way, why will you want to use the machine name when you already have an unique identifier like the "bid"/"delta" ??

  • 1
    Because I want to export the block with feature and that changes the block id on other site. After installation of boxes a machine name field is added to the block. – Sumit Madan Sep 6 '13 at 5:38
1

The "Drupal way" is to never use blocks directly, as theme shouldn't need any blocks to exist. Simplest way is to create a region. Regions have machine names all right. Then put your block into it. Features can export block to region associations.

  • Yeah but what about template files. I included the blocks there. I don't want to change that thing after importing the feature. – Sumit Madan Sep 6 '13 at 7:13
  • @SumitMadan Every time you need a region in your deeper tpl, just add it there. It was already asked and answered here how to do it. – Mołot Sep 6 '13 at 7:14
  • What about node.tpl.php?? – Sumit Madan Sep 6 '13 at 7:20
  • Use this and substitute html with node. That's all. If you'll fail doing it, please ask another question, specifically about making this work. I'm sure more generic question was there, but can't find it now. – Mołot Sep 6 '13 at 7:28

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.