0

It's easy to override an existing template in custom theme using one of the template suggestions or just by copying the desired template file and past it under custom theme templates directory.

But whenever you have an overriding template in your custom theme, and you desire to override that template in custom module you can do it by adding a new hook suggestion using hook_theme_suggestions_hook() or hook_theme_suggestions_alter() hooks, the problem is how to informe Drupal that the new added suggestion by the custom module should has a highest-priority than the one defined in custom theme, especially when the custom theme already used the existing highest-priority suggestion.

One of the proposed solution is using hook_theme_registry_alter(), but this is the wrong approach because it will always force the theme system to use the template declared in the custom module templates directory.

Is there an approach to have a full control on managing suggestions priorities ?

  • 2
    I don't understand the point of this question. You've already explained and answered everything really good yourself. Do you want to make something "unthemeable"? In that case you could use e.g. an inline-template – Hudri Jun 18 at 15:32
  • I just want to know how could I add a theme suggestion with highest-priority in a custom module, how to control the priority of new added suggestions, that's it. – MiharbKH Jun 18 at 15:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.