Search code examples
phpdrupaldrupal-7

Drupal Partial not being displayed


I have a footer partial

templates/partials/footer.tpl.php

Footer..

I have added it to the theme() hook in my template.php file

template.php

function scratch_theme($existing, $type, $theme, $path){
    return array(
       'footer' => array('template' => 'templates/partials/footer'),
    );
}

However when I am calling it it does not display

page.tpl.php

<?php $mainMenu = scratch_get_main_menu(); ?>

<div class="menu">
<ul>
    <?php foreach($mainMenu as $item){
    echo "<li>" . $item['link']['link_title'] . "</li>";
    }?>
</ul>
</div>

I have var dumped but to no i just get an empty string

Any help greatly appreciated


Solution

  • You've missed this bit from the docs:

    Each information array must contain either a 'variables' element or a 'render element' element, but not both

    So:

    function scratch_theme($existing, $type, $theme, $path){
        return array(
           'footer' => array(
             'template' => 'templates/partials/footer',
             'variables' => array(),
           ),
        );
    }
    

    and a cache clear should fix it