1

A designer has sent me a very cool design, and I don't know which is the .tpl file I need to override.

enter image description here

Basically, I need to put the title of the block between two fields of a view. The view is already a header of another view, and it displays only one record.

Other (bad) alternatives I see:

  • Do some positioning tricks with CSS.
  • Create a custom text field and style it like if it was the block title, and then hide the block title.
7
  • 2
    do you have multiple results in that view? or is it just one? plus: what have you used for that mockup? it looks great! Commented Mar 12, 2013 at 15:29
  • It's only one result because it's a header of another view.
    – Pere
    Commented Mar 12, 2013 at 15:37
  • For the mockup I've used a free account on moqups.com
    – Pere
    Commented Mar 12, 2013 at 15:39
  • I'd be very tempted by the second of your 'bad' alternatives. Views can be a bit mean with what is filtered in the Global: Custom text field, though for this custom css would see you right. If you are just using one row, you can exclude some of the rows from display and then pop a Global: Text area in the Header with a more liberal Text format. The Global: Text area makes available all your first row field values as tokens (which for you is only row). All of which said I do get that for some folks, code is preferable to fancy/hacky config, e.g. because of version control issues.
    – Obliquely
    Commented Mar 12, 2013 at 16:50
  • Code is preferable but I think I could override views-view-field.tpl for that. The problem I see is that styling a custom text as a title may cause me other troubles.
    – Pere
    Commented Mar 12, 2013 at 17:00

2 Answers 2

2

You could try Views block area

This module exposes all available blocks as a views area. This way you can add any block inside a footer or header from your view.

Also there is Views Hacks

Or i would do it with Views PHP by adding a field and print the block there with https://drupal.stackexchange.com/a/14354/4471

1
  • The first two solutions won't work for that, I think. The third could work, but I was looking for a proper solution
    – Pere
    Commented Mar 12, 2013 at 22:26
2

From here: http://themery.com/book/export/html/91 you need to create a file named like block--MODULE--DELTA.tpl.php

So for a views block I believe it's block--views--VIEWNAME-DISPLAYNAME.tpl.php

4
  • To pull individual fields out of the view in a block template may be tricky, though so your alternative suggestion of hiding the title and generating it as a field inside the view might work better in practice. Commented Mar 12, 2013 at 15:44
  • Yeah, I'm with @Alfred here. What you're looking for is actually printing some fields, then the title, then more fields. Editing the template should be enough. Although I'd copy over and edit the views-view-unformatted.tpl.php template from the Views module. Commented Mar 12, 2013 at 15:45
  • thanks, that was. But I cannot print the block title because $title is empty. And I would need to theme only the header display, which seems is not possible: views-view-unformatted--VIEWNAME--block.tpl is printing the display as a row.
    – Pere
    Commented Mar 12, 2013 at 16:45
  • Confirmed: Overriding views-view-unformatted.tpl.php cannot alter the block title
    – Pere
    Commented Mar 12, 2013 at 16:56

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.