Home > Drupal 7 > Drupal Theme Hook Suggestions Not Working

Drupal Theme Hook Suggestions Not Working


Keep in mind that the commonly-used Pathauto module uses path aliases. function drop_preprocess_node(&$variables) { if ($variables['promote']) { // looks for node--promoted.tpl.php in your theme directory $variables['theme_hook_suggestions'] = 'node__promoted'; } } // Add multiple suggestions for pages based on the logged in user's If you're doing anything with hook_preprocess_page() you are affecting the 'page'. Why is "Try Again" translated to やり直す? http://elliottwaveresearch.com/drupal-7/drupal-theme-hook-suggestions.html

If that's the case, then it's possible that Entity API is blocked from a stable release for a looonnng time. If the component is not a number, append "__" plus the component to the prefix. The theme registry does not have to be cleared for suggestions. The prefix of "drop" should be the name of your theme. // Add a single suggestion for nodes that have the "Promoted to front page" box checked. http://drupal.stackexchange.com/questions/52544/theme-hook-suggestions-is-ignoring-my-suggestions

Drupal Theme Hook Suggestions Not Working

US Election results 2016: What went wrong with prediction models? Log in or register to post comments Comment #23 fago CreditAttribution: fago commented January 22, 2013 at 4:23pm Status: Needs work » Needs review FileSize d7_entity_template_fix.patch860 bytes PASSED: [[SimpleTest]]: [MySQL] 374 Log in or register to post comments Comment #38 Alexander Allen CreditAttribution: Alexander Allen commented September 26, 2013 at 12:20am Status: Active » Fixed Paul B, According to comments #20 and Drupal’s online documentation is © 2000-2016 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0.

  • I've been caught out like that more than a few times now!
  • Notice: Trying to get property of non-object in templatename_process_page() (regel 100 van /srv/www/htdocs/site/themes/touch/template.php).
  • This also doesn't do anything and is ignored.
  • Theming the maintenance page must be properly setup first.
  • Suggestions only work if the original template exists too.
  • But now I also need a separate html.tpl.php for this, so I created the html--antenna.tpl.php and tried to add the code to mytheme_preprocess_html function to "activate" it but with no success.
  • Here's what I have so far in template.php: function mytheme_preprocess_page(&$vars, $hook) { // Add template suggestions based on content type if (isset($vars['node'])) { $vars['theme_hook_suggestions'][] = "page--type--" . $vars['node']->type; } } Devel

Thanks! How many seconds are a meter in the 4th dimension? Yes, I have rolandpish commented May 19, 2011 at 10:24pm Thanks iSOS. Drupal 7 Page Template For Content Type Log in or register to post comments worked but!

I created a page with the url http://_mysitename.com_/contact. For example, just creating an arbitrary template file (in this case 'newbies') instead of some system defined one like 'page--type--system--node......' etc.. After renaming my page.tpl.php to page--front.tpl.php I was able to see my changes but html.tpl.php still shows in devel_themer. https://www.drupal.org/node/1462772 Log in or register to post comments News itemsDrupal news Planet Drupal Association news Social media directory Security announcements Jobs Our communityCommunity Getting involved Services, Training & Hosting Groups & Meetups

will never work. Drupal Page Template For Content Type I tried to add these lines to the %themename%_preprocess_node() function: $vars['theme_hook_suggestions'][] = 'node__' . $field; $vars['theme_hook_suggestions'][] = 'node__' . $node->type; $vars['theme_hook_suggestions'][] = 'node__' . $field . '__' . $node->type; But it theming share|improve this question edited Jun 24 '13 at 9:06 Chapabu 12.9k22952 asked Dec 7 '12 at 15:29 Brandon 12615 add a comment| 2 Answers 2 active oldest votes up vote It helped me out greatly! ---Popolo - en webbyrå i Malmö som älskar Drupal Log in or register to post comments Totally worked catrina commented April 4, 2012 at 2:34am Note

Theme Debug Drupal 7

if (!empty($variables['page']['sidebar_first']) && !empty($variables['page']['sidebar_second'])) { $variables['classes_array'][] = 'two-sidebars'; } elseif (!empty($variables['page']['sidebar_first'])) { $variables['classes_array'][] = 'one-sidebar sidebar-first'; } elseif (!empty($variables['page']['sidebar_second'])) { $variables['classes_array'][] = 'one-sidebar sidebar-second'; } else { $variables['classes_array'][] = 'no-sidebars'; } other But that was months ago & I had forgotten this crucial 1st step. Drupal Theme Hook Suggestions Not Working amphioxus commented June 13, 2011 at 8:44pm Hurray, I finally got it to work because of this piece of code. Drupal 8 Theme Hook Suggestions Log in or register to post comments Change records for this issue Discover {$entity_type}.tpl.php templates if no custom template is defined Add child issue, clone issue News itemsDrupal news Planet Drupal

drupal themes preprocessor drupal-7 theming share|improve this question asked Apr 20 '11 at 14:13 maxedison 9,60494168 add a comment| 2 Answers 2 active oldest votes up vote 2 down vote Have this content This suggestion is used by default and the template file is located at "modules/poll/poll-results--block.tpl.php". See #1822338: Support theme template suggestions in entity module Problem/Motivation // Add suggestions. $variables['theme_hook_suggestions'][] = $entity_type; $variables['theme_hook_suggestions'][] = $entity_type . '__' . $bundle; $variables['theme_hook_suggestions'][] = $entity_type . '__' . $bundle . Log in or register to post comments Comment #4 tim.plunkett CreditAttribution: tim.plunkett commented March 15, 2012 at 11:15pm I'm able to set up a theme_ENTITY_TYPE(), but no matter what I do, Drupal Node Template

Log in or register to post comments Comment #10 freddybushboy CreditAttribution: freddybushboy commented July 25, 2012 at 4:06pm I had a similar problem which I managed to fix by adding this That's how this framework is designed. –Mołot Jun 24 '13 at 6:53 | show 1 more comment up vote 2 down vote I've struggled with this on many occasions and it And, honestly, calling the template functions ourselves might be overkill once that patch goes in. weblink more stack exchange communities company blog Stack Exchange Inbox Reputation and Badges sign up log in tour help Tour Start here for a quick overview of the site Help Center Detailed

See region.tpl.php in the Drupal API documentation for more information. Drupal 8 Theme Suggestions Log in or register to post comments thanks! current community chat Drupal Answers Drupal Answers Meta your communities Sign up or log in to customize your list.

thank you for helping me.

The default template for page is 'page.tpl.php'. These suggestions can be used when a specified condition is met and the suggested template exists. It's ignored. Drupal 7 Hook Theme So let's say you want to overwrite the page.tpl and your file is called: page--something-with-hyphens.tpl.php Then your hook should look something like that: mymodule_preprocess_page(&$vars) { if(something) { $vars['theme_hook_suggestions'][] = 'page__something_with_hyphens'; }

search-result--[searchType].tpl.php base template: search-result.tpl.php The same as above but for individual search results. If you had a block created by a custom module called "custom" and a delta of "my-block", the theme hook suggestion would be called "block--custom--my-block.tpl.php." Also one more example with Views, No luck there. check over here What I've done is added my suggestion to the theme_hook_suggestions array.

Log in or register to post comments Comment #7 mradcliffe CreditAttribution: mradcliffe commented March 22, 2012 at 3:05pm You're right, sorry. Giving change in smaller denominations so customers can tip? Although the template name in the line: $variables['theme_hook_suggestions'][] = 'page__node__sports'; should have underscores, the actual .tpl.php file should have hyphens instead. I've tried this: $variables['theme_hook_suggestions'][] = 'newbies'; This will add the 'newbies' suggestion to the array, but creating a 'newbies.tpl.php' file gets me nowhere.

Currently that does nothing without the patch above, or, injecting your own template suggestion via template.php.