0

I have a hook_theme instance in my template.php which outputs various components in my theme. I want to add an extra argument to one of the templates but no matter what I do it doesn't update. I have cleared the cache (using drush and not), removed the theme array, cleared cache and added back in. I have even truncated all the cache tables - but somehow it's still picking up the old function. Is there something stupid I have missed?

template.php

function MYTHEME_theme() {
  return array(

    'featured_blocks' => array(
      'arguments' => array(
        'blocks' => NULL,
        'image_format' => 'test!',
      ),
      'template' => 'featured-blocks',
      'path' => drupal_get_path('theme', 'MYTHEME') . '/templates/other'
    ),

  );
}

featured-blocks.tpl.php

<?php

printr($blocks); // blocks are all here
print $image_format; // this is undefined!!!

Calling the hook theme

<?php print theme('featured_blocks', array(
            'blocks' => $wrap->field_my_blocks,
            'image_format' => 'this is a test'
          )) ?>
  • You need to disable the module, and re/enable it. – kiamlaluno Jul 13 '16 at 3:56
  • What module? This is in my theme's template.php – Chris Jul 13 '16 at 4:12
  • in template.php, try public before function MY_THEME(); – innocent rock Jul 13 '16 at 4:13
  • 1
    Are you sure you're in the right theme folder? Maybe you have multiple dev servers for testing purposes, are you sure you're in the correct server? – No Sssweat Jul 13 '16 at 4:26
  • 1
    The idea of @ReesGargi was checking if that would cause a WSOD, or an exception being printed. If that happened, it meant the theme was the currently set theme, and Drupal caught the change. – kiamlaluno Jul 13 '16 at 4:36
0

After doing a bit more reading I restarted my MAMP server and switched themes, then back again. I'm not sure which did it but it's working now...

| improve this answer | |
  • did you mentioned it was a MAMP server? Drupal is weird on localhost – innocent rock Jul 13 '16 at 5:25

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.