1

I'm having a difficult time getting a view mode on an FPP to use my custom .tpl.php file.

Here is hook_preprocess:

function mymod_preprocess(&$variables, $hook) {
  $element = $variables['elements'];
  if ($element['#entity_type'] == 'fieldable_panels_pane') {    
    $entity_type = $element['#entity_type'];
    $bundle = $element['#bundle'];
    $view_mode = $element['#view_mode'];
    $variables['theme_hook_suggestions'][] = "{$entity_type}__{$bundle}__{$view_mode}";
    $variables['theme_hook_suggestions'][] = "fieldable-panels-pane-banner-banner-full-bleed";
    kpr($variables);
  }
}

The relevant output of the kpr() (the theme_hook_suggestions part of it:

array(3) { 
    [0]=> string(29) "fieldable_panels_pane__banner" 
    [1]=> string(48) "fieldable_panels_pane__banner__banner_full_bleed"     
    [2]=> string(46) "fieldable-panels-pane-banner-banner-full-bleed" } 

I hard-coded that last one thinking that it might just be a mishap in the naming conventions. I've tried every combination of dashes and underscores that I can think of; theme_devel isn't suggesting any of the ones in theme_hook_suggestions, the only ones it recommends are: panels-pane--fieldable-panels-pane--fpid-4.tpl.php < panels-pane--fieldable-panels-pane.tpl.php

I have the templates in /sites/all/modules/custom/mymod/templates with the module file in /sites/all/modules/custom/mymod/mymod.module.

Thanks for any direction!

  • What happens if you use $variables['theme_hook_suggestion'] = ... (remove the 's')? It should take precedence over all others. – othermachines Jun 24 '15 at 17:59
0

Two dashes for tpls. Your file should be named fieldable-panels-pane--banner--banner-full-bleed.tpl.php

| improve this answer | |
  • Thanks @fullerja but I've already tried all kinds of combinations, including that one. I thought maybe the /templates folder was getting loaded so I copied everything into the themes template folder with no luck. I just added some more information to the question - theme_devel is showing candidate template names but not the ones that correlate with the suggestions I add in hook_preprocess – Chris Rockwell Jun 24 '15 at 15:59
0

I think that your if statement is true for rendering any fields that are a part of the FPP, but not the FPP entity itself. Also, when I try your code, the 'elements' key doesn't seem to be defined when looking for suggestions for the FPP's display mode.

Also, you shouldn't need any handling in hook preprocess. Turn on $conf['theme_debug'] and look at your template suggestions, and create a template file with one of those in your theme. If it's not working, try one of the other name suggestions, you may just need something more specific. For me, this worked for a FPP bundle with the machine name "custom_markup_fpp"

ds-1col--fieldable-panels-pane-custom-markup-fpp.tpl.php

Picked from the suggestions:

<!-- FILE NAME SUGGESTIONS:
   * ds-1col--fieldable-panels-pane-custom-markup-fpp-full.tpl.php
   x ds-1col--fieldable-panels-pane-custom-markup-fpp.tpl.php
   * ds-1col--fieldable-panels-pane-full.tpl.php
   * ds-1col--fieldable-panels-pane.tpl.php
   * ds-1col.tpl.php
   * fieldable-panels-pane--custom-markup-fpp.tpl.php
   * fieldable-panels-pane.tpl.php
-->
| improve this answer | |

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.