4

My goal is to render an array of values (body, date) using my own theming function. I've read Using the theme layer, and checked out the example modules, and I can't see the reason why this isn't outputting the test string.

I've implemented registered my theme hook:

function mymod_theme() {
    $items = array(
        'mymod_items' => array(
            'variables' => array(
                'items'=>NULL
            ),
        ),
    );
    return $items;
}

I've implemented a theme function:

function theme_mymod_items($variables) {
    return 'I am themed output';
}

And I call this from my hook_block_view:

function mymod_block_view($delta = '') {
    switch($delta) {
        case 'mymod':
            $block['subject'] = t('My Module');
            $items = array(
                array('body'=>'body1','time'=>'time1'),
                array('body'=>'body2','time'=>'time2'),
                array('body'=>'body3','time'=>'time3'),
            );
            $block['content'] = theme('mymod_items',$items);
        break;  
    }
    return $block;
}

This results in the block not displaying, and the following message turning up in the log:

Theme key "mymod_items" not found.

Can someone please tell me what obviously essential step I've missed, or if I'm going in entirely the wrong direction?

5

It's an obvious answer, so sorry if you've tried it, but have you cleared your cache, specifically the theme registry?

  • 6
    Well, that was embarrassing. – shanethehat Dec 5 '11 at 23:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.