How to provide a specific node template in a custom module
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
2
down vote
favorite
I am using a custom module and using Bartik theme(from Drupal 8 core module) and hence need to define a content type specific template like node--[type].html.twig
I added hook_theme in my custom module as follows
function custom_autofill_reference_theme($existing, $type, $theme, $path)
drupal_set_message($path);
return [
'node' => [
'path' => $path . '/templates',
'template' => 'node',
],
];
but not sure on how to add a content type specific template in a custom module without the need to create a custom theme?
8 theming
add a comment |Â
up vote
2
down vote
favorite
I am using a custom module and using Bartik theme(from Drupal 8 core module) and hence need to define a content type specific template like node--[type].html.twig
I added hook_theme in my custom module as follows
function custom_autofill_reference_theme($existing, $type, $theme, $path)
drupal_set_message($path);
return [
'node' => [
'path' => $path . '/templates',
'template' => 'node',
],
];
but not sure on how to add a content type specific template in a custom module without the need to create a custom theme?
8 theming
You mean a content type specific template in a custom module without the need to create a custom theme?
â 4k4
1 hour ago
yes @4k4, I found the solution , I will send an answer for the same.
â harshal
54 mins ago
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I am using a custom module and using Bartik theme(from Drupal 8 core module) and hence need to define a content type specific template like node--[type].html.twig
I added hook_theme in my custom module as follows
function custom_autofill_reference_theme($existing, $type, $theme, $path)
drupal_set_message($path);
return [
'node' => [
'path' => $path . '/templates',
'template' => 'node',
],
];
but not sure on how to add a content type specific template in a custom module without the need to create a custom theme?
8 theming
I am using a custom module and using Bartik theme(from Drupal 8 core module) and hence need to define a content type specific template like node--[type].html.twig
I added hook_theme in my custom module as follows
function custom_autofill_reference_theme($existing, $type, $theme, $path)
drupal_set_message($path);
return [
'node' => [
'path' => $path . '/templates',
'template' => 'node',
],
];
but not sure on how to add a content type specific template in a custom module without the need to create a custom theme?
8 theming
8 theming
edited 41 mins ago
leymannx
6,06142356
6,06142356
asked 2 hours ago
harshal
3,13542355
3,13542355
You mean a content type specific template in a custom module without the need to create a custom theme?
â 4k4
1 hour ago
yes @4k4, I found the solution , I will send an answer for the same.
â harshal
54 mins ago
add a comment |Â
You mean a content type specific template in a custom module without the need to create a custom theme?
â 4k4
1 hour ago
yes @4k4, I found the solution , I will send an answer for the same.
â harshal
54 mins ago
You mean a content type specific template in a custom module without the need to create a custom theme?
â 4k4
1 hour ago
You mean a content type specific template in a custom module without the need to create a custom theme?
â 4k4
1 hour ago
yes @4k4, I found the solution , I will send an answer for the same.
â harshal
54 mins ago
yes @4k4, I found the solution , I will send an answer for the same.
â harshal
54 mins ago
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
/**
* Implements hook_theme().
*/
function custom_theme()
return [
'node__custom_content_type' => [
'base hook' => 'node',
],
];
Then make sure that you have the content type template under custom/templates/node--custom-content-type.html.twig
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
/**
* Implements hook_theme().
*/
function custom_theme()
return [
'node__custom_content_type' => [
'base hook' => 'node',
],
];
Then make sure that you have the content type template under custom/templates/node--custom-content-type.html.twig
add a comment |Â
up vote
3
down vote
/**
* Implements hook_theme().
*/
function custom_theme()
return [
'node__custom_content_type' => [
'base hook' => 'node',
],
];
Then make sure that you have the content type template under custom/templates/node--custom-content-type.html.twig
add a comment |Â
up vote
3
down vote
up vote
3
down vote
/**
* Implements hook_theme().
*/
function custom_theme()
return [
'node__custom_content_type' => [
'base hook' => 'node',
],
];
Then make sure that you have the content type template under custom/templates/node--custom-content-type.html.twig
/**
* Implements hook_theme().
*/
function custom_theme()
return [
'node__custom_content_type' => [
'base hook' => 'node',
],
];
Then make sure that you have the content type template under custom/templates/node--custom-content-type.html.twig
answered 53 mins ago
harshal
3,13542355
3,13542355
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdrupal.stackexchange.com%2fquestions%2f271787%2fhow-to-provide-a-specific-node-template-in-a-custom-module%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
You mean a content type specific template in a custom module without the need to create a custom theme?
â 4k4
1 hour ago
yes @4k4, I found the solution , I will send an answer for the same.
â harshal
54 mins ago