| Project: | Display Suite |
| Version: | 7.x-1.4 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Issue Summary
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.phpThe 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_defaultCan 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.
Comments
#1
@ 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__node1 (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?
#2
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
#3
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.phpds-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-pagerequires the file namecoconekosidebar--ds-views_collections-page.tlp.phpOne thing I do know, I put the suggested file into the default theme template folder, NOT in the ds_layouts folder.
#4
This will probably fix it - untested though, could you guys try.
Also, template files should be in your theme, never in the original folder.
#5
@ 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.phpbartik_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.phpds-2col-stacked--node-article.tpl.php
ds-2col-stacked--node-article-full.tpl.php
Thank you, Kristof for creating display suite :)
#6
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.
#7
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.
#8
@ 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:
ds-2col-stacked--node-article-full.tpl.phpds_2col_stacked__node_article_fullds-2col-stacked--node_article_full.tpl.phpThank you for your help.
#9
See this screenshot:
https://skitch.com/swentel/81tb7/fullscreen It works perfectly fine with dashes. (note, you need to clear cache for new templates)
#10
@ 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.