Download & Extend

How to name a template file that contains a colon.

Project:Panels
Version:7.x-3.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

I need to create a template file to theme a certain pane.
When i look at the theme_hook_suggestions, the 2nd suggestion would be perfect if I knew how to name the file. The suggestion is:

panels_pane__entity_field__node:field_overall_rating.

I got this far:
panel-pane--entity-field-[xxxx]tp.php

How do I finish the name?
Thanks.

AttachmentSize
pane theming suggestions.png26.78 KB

Comments

#1

Category:task» bug report

That's a bug in our code that isn't translating the : to an _ for the suggestion. You probably can't actually create a : in a suggestion name.

#2

So for now, I should add my own template file name to the theme_hook_suggestions[] array? (& thanks for your time.)

#3

Yes that's a good workaround.

If you're up for it, it should be a simple patch to preg_replace or maybe even ctools_cleanstring.

#4

I came across this issue as well. It looks like the patch from #1178334: Automatically detect panel pane template suggestions by pane type is using strtr on string that has not been cleansed.

// Add template file suggestion for content type and sub-type.
$vars['theme_hook_suggestions'][] = $base . $delimiter . $content->type;
$vars['theme_hook_suggestions'][] = $base . $delimiter . strtr($content->type, '-', '_') . $delimiter . strtr($content->subtype, '-', '_');

I'll see if I can create a patch for this.

#5

Version:7.x-3.2» 7.x-3.x-dev
Component:Panel nodes» Code
Status:active» needs review

I've attached a patch that runs $content->type and $content->subtype through ctools_cleanstring before performing strtr. I looked at the new template suggestions and the colon is now replaced with a _.

What used to be:
panels_pane__entity_field__node:field_birthday

is now:
panels_pane__entity_field__node_field_birthday

AttachmentSize
panels-fixed_colon_in_template_suggestions-1599374-5.patch 888 bytes

#6

Status:needs review» fixed

Thanks a ton! Committed and pushed.

#7

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

nobody click here