Needs work
Project:
Views (for Drupal 7)
Version:
7.x-3.x-dev
Component:
block displays
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
12 Nov 2009 at 23:00 UTC
Updated:
2 May 2014 at 14:08 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
dawehnerThats not how you should implement this! Use hook_preprocess_block and add template suggestions.
Comment #2
nicholas.alipaz commentedThanks for the correction. I still think this should be added as an option in views.
Comment #3
dawehnerMy code will not work..
Comment #4
merlinofchaos commentedJust an FYI, this will only work if the view name, the dash, and the display ID all add up to 32 characters or less. If longer, the delta becomes an MD5 hash because the delta isl imited to 32 characters.
Comment #5
dawehnerDo you know a way to fix this?
Comment #6
nicholas.alipaz commentedI am using this in my template.php:
There may be a better way however. Also, one needs to check for the MD5 hash if it is too long as merlinofchaos mentioned.
Comment #7
merlinofchaos commentedI believe anything placed inthe $block array returned by hook_block() will make it to the template. We can put data in there, and use hook_preprocess_block() to add suggestions based on that data, perhaps.
Comment #8
nyl_auster commentedHello
Is there something new about that ? templates block name with md5 happen very often if you work on a big site with very descriptive name for the blocks.
Is there a way, playin with preprocess, to pass to the preprocess_block the name of the view ?
Comment #9
nyl_auster commentedreal name of the views is registered in the variable table
here is the snippet code i use to add a suggestion template for the realname of the views (name + display-id) for the blocks, if delta became a md5.
This go in a themename_preprocess_block() :
Comment #10
dawehnerHere is a patch
Comment #11
dawehnerdoah
Comment #12
dawehnerIt works find on 6.x-3.x. Needs porting to d7.
Comment #13
nicholas.alipaz commentedtested and works for me. 6.x-3.x-dev
Comment #14
phoenix commentedHi
I encountered the same problem to style a specific views block. But the weirdest thing is that the template should be in the template suggestions of core drupal 7. Check here: http://drupal.org/node/1089656
block--[region|[module|--delta]].tpl.php
But it's not working for me. Even when using some code from above to add the template suggestion in theme_preprocess_block, it doesn't work.
Any ideas for views 7.x-3.0-beta3 on drupal 7?
Comment #15
dgastudio commentedsub
Comment #16
paulgemini commentedsubing
Comment #17
dawehnerHere is a patch for d7.
It would be great if some people could test it.
Comment #18
dawehnerDoes this really work? Isn't the preprocess runned after the lifetime of the view-object?
Comment #19
tim.plunkettTriggering the testbot.
Comment #21
epiphanydigital commentedThis works out of the box.
Just name the tpl file you need as follows:
block--views--view_machine_name.tpl.php
Comment #22
amuhlou commentedIt does work out of the box, but the underscores should be replaced with single hyphens -
block--views--view-machine-name.tpl.php