Acquia Cohesion renames to Site Studio from version 6.2. Tell me more.

    Implementing hooks for custom content entities

    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__

    DX8 knowledge base icon

    Frequently asked questions

    Get instant answers to common questions. Available online 24/7.

    Find answers

    Raise a ticket icon

    Raise a support ticket

    To raise a ticket, sign into Acquia Cloud and select Help in the top menu.

    Raise support ticket


    Copyright © 2020 Acquia, Inc. All Rights Reserved. Drupal is a registered trademark of Dries Buytaert.