How to provide a specific node template in a custom module

The name of the pictureThe name of the pictureThe name of the pictureClash 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?










share|improve this question























  • 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
    47 mins ago
















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?










share|improve this question























  • 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
    47 mins ago












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?










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 35 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
    47 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










  • yes @4k4, I found the solution , I will send an answer for the same.
    – harshal
    47 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
47 mins ago




yes @4k4, I found the solution , I will send an answer for the same.
– harshal
47 mins ago










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






share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "220"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    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






























    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






    share|improve this answer
























      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






      share|improve this answer






















        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






        share|improve this answer












        /**
        * 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







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 46 mins ago









        harshal

        3,13542355




        3,13542355



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            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













































































            Comments

            Popular posts from this blog

            Long meetings (6-7 hours a day): Being “babysat” by supervisor

            Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

            Confectionery