I create 2 views with tag: "t_news". And I would to theme output. I put file named "views-view-grid--t-news.tpl.php" in my theme folder. But when I start scan folder for theme files nothing find. I rename my tag to "tnews" and rename my file to "views-view-grid--tnews.tpl.php" and it starts to work.

This means that tag names should not contain "_" characters

Comments

esmerel’s picture

Assigned: Unassigned » esmerel

Should be testable.

esmerel’s picture

Version: 6.x-2.8 » 6.x-2.10

I'm able to replicate this; the file is definitely there, but the theme information is not picking it up.

esmerel’s picture

Assigned: esmerel » Unassigned
dawehner’s picture

Yes, the problem is that the theme system replaces _ with -

dawehner’s picture

Perhaps views should do this on the admin page, too.

tic2000’s picture

I actually did replicate this problem using a - in my tag too.

myxelf’s picture

Title: _ in views tags » Template file based on Views' tag won't be picked up if tag contains non-alphanumeric characters
Version: 6.x-2.10 » 6.x-2.11
Component: Miscellaneous » Code
Status: Active » Needs review

This behaviour will occur when the Views' tag contains any non-alphanumeric character.

The issue is coming from the solution given to: #354270: Allow Views Templates to Affect Views Output by Tag.

In theme/theme.inc:

$themes[] = $hook . '__' . preg_replace('/[^a-z0-9]/', '-', strtolower($view->tag));

This line is saying that all characters different from letters and numbers will be converted to a *hyphen*. Resulting in a mixture of underscores and hyphens, that later won't match in format_themes() inside plugins/views_plugin_display.inc, specifically in: if (!$picked && !empty($registry[$theme])). Because the entries in $registry are using only *underscores* and $theme is mixed with *hyphens*.

The line should be (note the *underscore* inside the preg_replace() function:

$themes[] = $hook . '__' . preg_replace('/[^a-z0-9]/', '_', strtolower($view->tag));

I have tried it and it works.

HTH

MyXelf

PS: I'm changing the title to something more descriptive. I'll also set the status to 'Needs Review' despite there is no patch attached, cause only one char needs to be changed. If you think that attaching a patch is required, I'll do it. Feel free to modify the information to whatever you see fits best.

dawehner’s picture

A patch helps people to do the same and allows the developer of views to apply this fix.

dawehner’s picture

Status: Needs review » Needs work

Please create one :)

myxelf’s picture

Here you have it.

Thanks

myxelf’s picture

Status: Needs work » Needs review

Changing the status

tic2000’s picture

Status: Needs review » Reviewed & tested by the community

I tested the patch using a tag with "-" and one with "_" and for both the template file suggested by Views worked now.

merlinofchaos’s picture

Status: Reviewed & tested by the community » Fixed

Committed to all branches.

Status: Fixed » Closed (fixed)

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

codycraven’s picture

Version: 6.x-2.11 » 6.x-2.12
Status: Closed (fixed) » Needs review

Re-opened.

The same problem exists in 6.12. The patch in #10 still fixes the problem.

merlinofchaos’s picture

Status: Needs review » Closed (fixed)

Please don't re-open committed patches just because they're not yet in a published release.

codycraven’s picture

Status: Closed (fixed) » Needs review

merlinofchaos you commented that you committed the patch on October 12th. 6.x-2.12 was released on December 15th. I was assuming this was a regression. The patch is indeed present in the DRUPAL-6--2 branch, forgive my re-opening.

codycraven’s picture

Status: Needs review » Closed (fixed)
merlinofchaos’s picture

You should read 2.12's release notes.