---
title: "Implementing hooks for custom content entities"
date: "2017-12-20T10:36:50+00:00"
summary: "Learn how to implement hooks for custom content entities in Site Studio. Discover step-by-step instructions for altering theme suggestions and ensuring compatibility with your Drupal setup. Enhance your development workflow today."
image:
type: "page"
url: "/drupal-starter-kits/add-ons/site-studio/implementing-hooks-custom-content-entities"
id: "c58c1277-b116-414c-b089-a364b77d9dce"
---

To make your custom content entity work with Site Studio, you will need to alter the suggestions using _hook\_theme\_suggestions\_HOOK\_alter_. Site Studio provides a method you can implement inside the hook that will alter the suggestions according to your Site Studio setup

    cohesion_templates_suggestions(array &$suggestions, ContentEntityInterface $entity, $view_mode, $hook)

  
The first argument is the array of suggestions, and the second argument is the entity you are altering the suggestions for, ( usually in $variables\['elements'\]\[entity\_type\] ), the third argument is the view mode used to render the entity, and the last argument the entity type.

For example, if you want to enable paragraphs you need to implement the hook _hook\_theme\_suggestions\_HOOK\_alter_ using the cohesion\_templates\_suggestions method as follows:

    /**  
     * @inheritdoc  
     * Implements hook_theme_suggestions_HOOK_alter().  
     *  
     */ 
    function MY_MODULE_theme_suggestions_paragraph_alter(array &$suggestions, array &$variables) {   
      cohesion_templates_suggestions($suggestions, $variables['elements']['#paragraph'], $variables['elements']['#view_mode'], 'paragraph'); 
    } 
    

  
Most of the time, the base theme hook is the same as the entity type name. Therefore Site Studio takes the entity\_type to generate its twig file (ex: for a node template the generated twig will have a name of node\_\_template-name). However, if the entity\_type doesn't match the base theme hook, you will have to implement a Site Studio hook _hook\_cohesion\_templates\_ENTITY\_TYPE\_base\_hook\_alter_ to provide the right base hook name.

You can find an example of this in the cohesion\_template.module 

    /**  
     * @inheritdoc  
     * Implements hook_cohesion_templates_ENTITY_TYPE_base_hook_alter().  
     *  
     */ 
    function MY_MODULE_cohesion_templates_block_content_base_hook_alter(&$base_hook) {   
      $base_hook = 'block'; 
    }
    

  
Without this implementation, twig file names for custom blocks would start with _block\_content\_\__ where it has to be _block\_\__