0

I have a View called News which has about 10 different block displays in it serving various roles. I created a template for the first block (not block_1 and not the master) in order to apply some unique structure.

Though the changes are seen on all the blocks in News.

Based on the template suggestions for the block I need it to apply to, it suggests the following.

Display output: views-view.tpl.php, views-view--news.tpl.php, views-view--default.tpl.php, views-view--default.tpl.php, views-view--block.tpl.php, views-view--news--block.tpl.php

I'm using views-view--news--block.tpl.php since its the most granular of the options.

Is there another I should use?

7
  • Does it work with the ID of the block display instead? e.g. if the display ID is block_1, the template might be views-view--news--block-1.tpl.php
    – Clive
    Commented Apr 11, 2018 at 19:06
  • That's what I mentioned in the OP, it's not block_1, just block. The following view is block_1 which I don't want to touch. Commented Apr 11, 2018 at 19:07
  • So machine wise it goes default,block,block_1,and so on. So hitting "block" as the machine name is apparently applying to all blocks in the view versus just that one. basically there should be a block_0 option. Commented Apr 11, 2018 at 19:09
  • Oh sorry, must not have read it properly. You’ll have to implement hook_preprocess_view and manually remove that suggestion where it’s not wanted, block is a hard coded display type ID in Views, and your desired display ID conflicts with it - Views has no natural way for you to tell it that you don’t want the standard template naming to apply in that instance, so you have to override it
    – Clive
    Commented Apr 11, 2018 at 19:14
  • Oh, it sounds like maybe Views set the ID to block as standard, that wasn't something you changed? In that case there must be an easier way, I'm sure a bug like that wouldn't have been left unfixed for so long. I'll have a peek at the code
    – Clive
    Commented Apr 11, 2018 at 19:20

1 Answer 1

0

Simply changing the machine name setting on the display allows me to make it what I want, so I gave it the machine name block_0 and now I can make a designated template for it.

Your Answer

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

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