On the views displays "manage layout" settings for a "views template" you get a list of possible template suggestions. In my case this is:

You have selected the Two column stacked layout. The default template can be found in sites/all/modules/ds/layouts/ds_2col_stacked

Possible template suggestions are:

    ds-2col-stacked--ds-views.tpl.php
    ds-2col-stacked--ds-views-mailchimp-content-page.tpl.php


The first template suggestion works as expected. The second one doesn't get found. Looks like that template suggestion isn't being picked up or it has some underscore vs hyphen problem.

When I dump the variables from $vars['theme_hook_suggestions'] I get:

... (Array, 4 elements)

    0 (String, 15 characters ) ds_2col_stacked
    1 (String, 25 characters ) ds_2col_stacked__ds_views
    2 (String, 48 characters ) ds_2col_stacked__ds_views_mailchimp_content-page
    3 (String, 56 characters ) ds_2col_stacked__ds_views_mailchimp_content-page_default


Can someone confirm the suggestions with the element bundle doesnt work as expected?

The only way I could make it work was by replacing the element bundle's hyphens with underscores and also renaming the template file to: ds-2col-stacked--ds-views-mailchimp_content_page.tpl.php. But that just feels wrong. I thought template files should always use hyphens...

Any help is appreciated.

CommentFileSizeAuthor
#4 1406630.patch1.11 KBswentel

Comments

rpmskret’s picture

@ Mywebmaster
I am also struggling to understand how to use the template suggestions with display suite.
I do not find anything from ds when I tried a kpr() of $vars['theme_hook_suggestions'] . Only standard suggestions like ..

0 (String, 10 characters ) page__node
1 (String, 13 characters ) page__node__%
2 (String, 14 characters ) page__node__59

I did the kpr() from bartik_preprocess_page(&$vars) in template.php . In my case on the "manage layout" page ds
provides this:

Possible template suggestions are:

ds-2col-stacked--node.tpl.php
ds-2col-stacked--node-article.tpl.php
ds-2col-stacked--node-article-full.tpl.php
ds-2col-stacked--node-article-teaser.tpl.php
ds-2col-stacked--node-article-default.tpl.php

May I ask (?) : from which file and function did you get your output of the theme_hook_suggestions?
I tried all sorted of perms and combs for file names and suggestion names and only the original ds node template is used.
Also (?): Where did you place your temple file, ie. ds-2col-stacked--ds-views-mailchimp_content_page.tpl.php?
I have spent much time trying to work this out. But I still need help!

EDIT >>> 19:50 PM 1/29/2012

I have managed to get this much to work:
Created the file ds-2col-stacked--node_article_teaser.tpl.php in the current theme templates directory. Now
on most of the expected pages this file is used. However there seems an issue related to the Page manager: node_view is not compatible with display suite extra "View mode per node". I had switched off that extra and then later on again. Now some of the pages respect
the temp-suggestion and some don't. And some pages do not update when the display is edited. Page manager is very nice
and I intend to try to limit conflicts and just develop without the display suite extra "View mode per node".

As far as the file naming goes for the tpl's so far it seems that you use the dash "-" until the double "--". And then you guess where to finish with underscores "_".
This is not good.
We need the brains-from--brussels >> swentel are you there?

paul.linney’s picture

Hi,

I'm also having an issue with these template themes suggestions. Here is the output from ds.module after the suggestion names are created:

Array
(
    [0] = coconekosidebar
    [1] = coconekosidebar__ds_views
    [2] = coconekosidebar__ds_views_collections-page
    [3] = coconekosidebar__ds_views_collections-page_default
)

I've tried every possible combination of underscores and hyphens, try to get it to see the template file. and I've just been putting it in the same folder as the `ds_layout/coconeko`.

The filename I though should work is: coconekosidebar--ds-views-collections-page.tpl.php

Any ideas what to name the file?

Paul

rpmskret’s picture

Hi Paul. I find it very unclear how to use this useful feature of template suggestions with Display Suite.
But I have got it working now.
The file name: I used the clues given on the "manage layout" page for the display in question.
You get suggestions like this:

     ds-2col-stacked--node.tpl.php
    ds-2col-stacked--node-article.tpl.php

Please see my post #1 above for more. Use "-" in the file name until the double "--". Then use "_". But in your case
this might not quite work. My first GUESS would be perhaps ..
coconekosidebar__ds_views_collections-page requires the file name coconekosidebar--ds-views_collections-page.tlp.php

One thing I do know, I put the suggested file into the default theme template folder, NOT in the ds_layouts folder.

swentel’s picture

Status: Active » Needs review
StatusFileSize
new1.11 KB

This will probably fix it - untested though, could you guys try.

Also, template files should be in your theme, never in the original folder.

rpmskret’s picture

@ swentel :
Thank you for your help!
I manually applied the patch. Confession: don't want to install cygwin to apply patch on overloaded windows.
Is this what you intended?

if (isset($layout['module']) && $layout['module'] == 'panels') {
        $layout['layout'] = $layout['panels']['theme'];
      }

			$bundle = strtr($vars['elements']['#bundle'], '-', '_'); // +
      $vars['theme_hook_suggestions'][] = $layout['layout'];
      $vars['theme_hook_suggestions'][] = $layout['layout'] . '__' . $vars['elements']['#entity_type'];
      //$vars['theme_hook_suggestions'][] = $layout['layout'] . '__' . $vars['elements']['#entity_type'] . '_' . $vars['elements']['#bundle'];
      //$vars['theme_hook_suggestions'][] = $layout['layout'] . '__' . $vars['elements']['#entity_type'] . '_' . $vars['elements']['#bundle'] . '_' . $vars['elements']['#view_mode'];
      $vars['theme_hook_suggestions'][] = $layout['layout'] . '__' . $vars['elements']['#entity_type'] . '_' . $bundle; // +
      $vars['theme_hook_suggestions'][] = $layout['layout'] . '__' . $vars['elements']['#entity_type'] . '_' . $bundle . '_' . $vars['elements']['#view_mode']; // +

That is what I did. There is no change resulting from this patch.
kpr($vars['theme_hook_suggestions'] ); output from template.php bartik_preprocess_page(&$vars)
shows only the drupal core suggestions, no ds stuff. And the custom template ds-2col-stacked--node_article_full.tpl.php in my theme template folder is a working instance that does get used for article pages in full display. Same as before the patch.

May I ask, what is the patch hoping to change?
Main troubles to me are the template suggestions are nowhere to be found with the proper naming.
Oh ya, at ~types/manage/article/display/full the same as before the help text is:
Possible template suggestions are:

ds-2col-stacked--node.tpl.php
ds-2col-stacked--node-article.tpl.php
ds-2col-stacked--node-article-full.tpl.php

Thank you, Kristof for creating display suite :)

swentel’s picture

What the patch is changing is, in case the bundle has a dash instead of an underscore, which happens for display suite views, turn dashes into underscores. With the dash, the theming system is going to flip and not find the right template. It's not going to affect bundles without dashes, so you won't see anything happening for simple content types. This really only affects views at this point as far as I know.

rpmskret’s picture

ok then. You'll need some other testers. For now I'm in your simple content class, ya. No views involved right now.
Anyway I will watch how things go here.

rpmskret’s picture

@ swentel :
Hi. Can you try to get some sort of help into display suite to aide people w/ these temp. suggs? After hours of searches and work on computer with ds it just came down to guessing what to name the template files to use for template suggestions.

A real example for my article/display/full display mode:

  1. Help text @ ~types/manage/article/display/full: ds-2col-stacked--node-article-full.tpl.php
  2. kpr() output from file ds.module: ds_2col_stacked__node_article_full
  3. A guess that works: ds-2col-stacked--node_article_full.tpl.php

Thank you for your help.

swentel’s picture

See this screenshot:
https://skitch.com/swentel/81tb7/fullscreen It works perfectly fine with dashes. (note, you need to clear cache for new templates)

rpmskret’s picture

@ swentel
All dashes, yes, it does work. Nice. I really appreciate your help. Lots of time on this little spot but not insignificant the functionality you get w/custom-templates.
I have been aware of the cache clear requirement. I updated ds yesterday and perhaps that made a change. But I know I can be ever so careful sometimes and yet miss understand or erroneously test something.

swentel’s picture

Status: Needs review » Closed (works as designed)

Closing for now. Please open a new one in case this is still a problem.

stephenplatz’s picture

Version: 7.x-1.4 » 7.x-2.6

The theme_hook_suggestions array contains the following elements

0 (String, 15 characters ) ds_2col_stacked
1 (String, 25 characters ) ds_2col_stacked__ds_views
2 (String, 33 characters ) ds_2col_stacked__ds_views_default
3 (String, 39 characters ) ds_2col_stacked__ds_views_search-page_5
4 (String, 47 characters ) ds_2col_stacked__ds_views_search-page_5_default

and the UI suggests

ds-2col-stacked--ds-views.tpl.php
ds-2col-stacked--ds-views-search-page-5.tpl.php

I've tried as many iterations, exchanging dashes for underscores, as I can imagine, without the template being respected. I could open a new issue, as suggested, but I think this issue is probably related to the above. I should mention, ds-2col-stacked--ds-views.tpl.php works as expected, but anything more specific does not. I'm wondering if, strangely, this has anything to do with a 39+ character string file name. I wonder how to find out.

EDIT: The patch at #4 failed (Hunk #1 FAILED at 924).

lmeurs’s picture

Version: 7.x-2.6 » 7.x-2.x-dev
Status: Closed (works as designed) » Active

@stephenplatz: At admin/structure/ds/vd/manage/my_view_id-page/display the UI indeed wrongly suggests to use ds-1col--ds-views-my-view-id-page.tpl.php. This template could not be found, on the other hand it did work after adding an extra dash after 'ds-views', ie. ds-1col--ds-views--my-view-id-page.tpl.php

lmeurs’s picture

I have to stand corrected, the double dash did not solve the problem. I manually applied the patch from #4 and this did work for my views template, both at admin/structure/ds/vd/manage/my_view_id-page/display suggested TPL's work! :-)

lmeurs’s picture

Status: Active » Reviewed & tested by the community
aspilicious’s picture

Version: 7.x-2.x-dev » 8.x-2.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Needs porting

  • aspilicious committed 9f3de4a on 7.x-2.x authored by swentel
    Issue #1406630 by swentel: Views Displays: template suggestions
    
lmeurs’s picture

The patch from this issue has been committed on 2015-01-28, though did not make it to the 7.x-2.8 stable release of 2015-04-15. Currently the most recent development version is 7.x-2.7+30-dev which has been released on 2015-04-16.

Was 7.x-2.8 maybe based on the stable release of 7.x-2.7 (to quickly get the security bugs fixed) and does that explain why the patch from this issue did not make it to 7.x-2.8? Shouldn't the dev version get bumped to 7.x-2.8+xxx-dev?

#2474391: Upgrade to ds ver 2.8 give 'undefined index: reply in ds entity variables' might be related.

Thanks in advance!

aspilicious’s picture

this is correct, the security team asked me to only add the security patch on top of 2.7. if you were on a dev release you should stay on a dev release.

lmeurs’s picture

@aspilicious: Thanks for the quick explanation!

bceyssens’s picture

Status: Patch (to be ported) » Closed (won't fix)

This option doesn't exists in D8