Home > Drupal 7 > Drupal Theme Hook Suggestions Not Working

Drupal Theme Hook Suggestions Not Working

Contents

function drop_preprocess_page(&$variables) { if ($variables['node']->type != "") { $variables['template_files'][] = "page-node-" . $variables['node']->type; } } Now just make your template in form page-node-your_content_type. Some pages might be temporarily missing, and some guides might appear empty. reply Thanks!! Let me know if you have more trouble. check over here

Did I cheat? Anyone know what's going on? News itemsDrupal news Planet Drupal Association news Social media directory Security announcements Jobs Our communityCommunity Getting involved Services, Training & Hosting Groups & Meetups DrupalCon Code of conduct DocumentationDocumentation Drupal 8 The default is to use it for nodes but a suggestion is made for rendering them inside block regions. view publisher site

Drupal Theme_hook_suggestions

This is the scenario: I have four "Basic Page" pieces of content that will use the same template file. I have been working with 7 for a few weeks and finally decided to see if I could get the template suggestions to work. Drupal will use the most specific template it finds: For forum containers: forums--containers--forumID.tpl.php forums--forumID.tpl.php forums--containers.tpl.php For forum topics: forums--topics--forumID.tpl.php forums--forumID.tpl.php forums--topics.tpl.php See forums.tpl.php in the Drupal API documentation for more information.

  • For example, by default with no suggestions in both 6 and 7, you could create a template for a node type.
  • For instance, if we wanted to alter the theme suggestions for all of our Pages, then we could use silo_theme_suggestions_page_alter().
  • taxonomy-term--[vocabulary-machine-name|tid].tpl.php base template: taxonomy-term.tpl.php Theme hook suggestions are made based on these factors, listed from the most specific template to the least.
  • And who are »they«?
  • This also doesn't do anything and is ignored.
  • Skip to Main Content Search Search this site: Home Drupal Git Linux/SSH MySQL PHP Snippets Sunday, November 13, 2016 07:27 am EST Home » Blogs » Bri's blog Donate If my
  • Let's applythe getRouteObject() method to our request object, like so: function silo_theme_suggestions_select_alter(&$suggestions, &$vars, $hook) { $request = \Drupal::routeMatch()->getRouteObject(); kint($request); } A page-refresh should reveal the following information: Look at all
  • File extensions are not present because these hooks can be implemented as theme functions or template files.

Adding to the array should be done with a general condition first, progressively getting more specific so it cascades based on specificity. In this case, the “select” element only has the “select.html.twig” template suggestion. reply Hasty post! Drupal Page Template For Content Type Luckily, theme hook suggestions also exist for many theme functions, and Drupal core has implemented suggestions for some of the popular theme functions, like theme_links().

Can Newton's laws of motion be proved (mathematically or analytically) or they are just axioms? Theme Debug Drupal 7 This keeps it clear and the files grouped together. I've already coded page.tpl.php for other "Basic Page" content. http://drupal.stackexchange.com/questions/52544/theme-hook-suggestions-is-ignoring-my-suggestions Armistice Day Challenge Why were pre-election polls and forecast models so wrong about Donald Trump?

Some Example Template Suggestions for theme_links()Suggestion Theme Function Equivalent Description links THEME_links() Default implementation, which is used for all implementations unless a more specific implementation like those Drupal 8 Theme Suggestions This allows Drupal to fall back on the generic theme hook, which in this case is block, and use block.tpl.php when a more specific template, like block--module.tpl

Theme Debug Drupal 7

However, attempting to create a template file using a path that was created using a custom alias (or the Pathauto module) such as about/team for a node/1 will share|improve this answer edited Apr 20 '11 at 15:59 Laxman13 5,09831426 answered Apr 20 '11 at 14:44 maxedison 9,60494168 add a comment| Your Answer draft saved draft discarded Sign up Drupal Theme_hook_suggestions comment-wrapper--node-[type].tpl.php base template: comment-wrapper.tpl.php Similar to the above but for the wrapper template. Drupal Node Template Did Trump call Belgium a village in Europe?

A reference for "a generalized quaternion group has a unique element of order 2". http://sevevb.com/drupal-7/drupal-7-hook-install-not-working.html You must provide your own template for it to take effect. Why are auto leases stubbornly strict about visa status and how to work around that? Overriding themable output Overriding themable output Beginners guide to overriding themable output Introduction to PHP for theming About overriding themable output Setting up variables for use in a template (preprocess and Drupal 8 Theme Hook Suggestions

But perhaps I'm not understanding? Is the untested/empty statement true? For example, a template file called node.tpl.php and a function called theme_node() share the same node theme hook. this content Template Suggestions for BlocksSuggestion Template File Equivalent Description block block.tpl.php Default block implementation.

I was running [theme]_preprocess_html and not [theme]_preprocess_page, so it was indeed leaving out the Node. Drupal 7 Page Template For Content Type That is where my code comes in handy by suggesting two different templates for the two different pages. Why is (a % 256) different than (a & 0xFF)?

Lab colleague uses cracked software.

You should accept your answer :) –Cottser Aug 21 '15 at 13:10 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google The options and naming patterns vary depending on what type of object you are working with. field--[type|name[--content-type]|content-type].tpl.php base template: field.tpl.php Theme hook suggestions are made based on these factors, listed from the most specific template to the least. Drupal 7 Hook Theme But the template suggestion just isn't working.

Tip Use the dpm() function (provided with the Devel module) inside the generic template file you are working with to find out what options are available. dpm--block.tpl.php and a block created by the menu module would be targeted by using block--menu.tplhave a peek at these guys During the preprocess stage, before each template is rendered, a variable called $theme_hook_suggestions is created and populated with alternative hook suggestions.

Update the function by adding a condition for producing a theme suggestion based on the $request variable: function silo_theme_suggestions_select_alter(&$suggestions, &$vars, $hook) { $request = \Drupal::routeMatch()->getRouteObject()->getDefault('view_id'); if (!empty($request)) { For the teaser portion, I would opt to use the $teaser flag in the already provided node--[content-type].tpl.php files (by default) to alter the display for that (http://api.drupal.org/api/drupal/modules--node--node.tpl.php/7/source). more hot questions question feed default about us tour help blog chat data legal privacy policy work here advertising info mobile contact us feedback Technology Life / Arts Culture / Recreation