Right now STARTERKIT/template.php has

function STARTERKIT_theme(&$existing, $type, $theme, $path) {
  return zen_theme($existing, $type, $theme, $path);
}

But its non-obvious how to modify that function if you want to extend that HOOK_theme for your own nefarious purposes. ;-)

I'm going to change it to:

function STARTERKIT_theme(&$existing, $type, $theme, $path) {
  $hooks = zen_theme($existing, $type, $theme, $path);
  // Add your theme hooks like this:
  /*
  $hooks['hook_name_here'] = array( // Details go here );
  */
  // @TODO: Needs detailed comments. Patches welcome!
  return $hooks;
}

Comments

johnalbin’s picture

Status: Active » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

zmove’s picture

Status: Closed (fixed) » Active

sorry, don't read this stupid post...

zmove’s picture

Status: Active » Closed (fixed)
akahn’s picture

Category: bug » task
Status: Closed (fixed) » Active

I think a good start for making this more clear would be referring to the API documentation in the comments: http://api.drupal.org/api/function/hook_theme/6

Also, the comment could explain that $hooks = zen_theme($existing, $type, $theme, $path); is what loads up the theme functions from the Zen base, while $hooks['hook_name_here'] is where you add your subthemes hooks before returning the whole $hooks collection. It could also point out more clearly that hook_name_here corresponds, simply, to a function somewhere in template.php.

Lastly, and I'm not sure how this could be done well, is explain that what $hooks['hook_name_here'] is assigned to is an array of the arguments that the newly registered theme function takes. I don't know how this should be done, but the examples on the hook_theme() documentation page helped for me. I guess it would be best if this were documented in a handbook in a friendly way in addition to the API documentation.

Basically, this was confusing for me to figure out, and I finally did it, and I want it to be more clear for others in the future. ;) Thoughts?

raimondious’s picture

Basically, this was confusing for me to figure out, and I finally did it, and I want it to be more clear for others in the future. ;) Thoughts?

I'm struggling with it right now, and still confused after reading your post. Could you explain what you did to get it working? Then I'll try to say it back to you, and maybe we can get some clear wording out of the exchange.

wickwood’s picture

Version: 6.x-1.x-dev » 6.x-1.0
Component: Code » Documentation

I can't get this to work either.

I'm trying to theme the user registration form based on the tutorial at:
http://11heavens.com/theming-the-register-form-in-Drupal-6

I have this for my hook theme function:

function gdems3_theme(&$existing, $type, $theme, $path) {
  $hooks = zen_theme($existing, $type, $theme, $path);
  // Add your theme hooks like this:
  /*
  $hooks['hook_name_here'] = array( // Details go here );
  */
  $hooks['user_register'] => array( 'arguments' => array('form' => NULL),
                                                    // and if I use a template file, ie: user-register.tpl.php
                                                   'template' => 'user-register',
                                           );
  																
  // @TODO: Needs detailed comments. Patches welcome!
  return $hooks;
}

And I created this preprocess function based on the others in the template.php

/**
 * Override or insert variables into the user_register form templates.
 *
 * @param $vars
 *   An array of variables to pass to the theme template.
 * @param $hook
 *   The name of the template being rendered ("user-register" in this case.)
 */

function gdems3_preprocess_user_register(&$vars, $hook) {
  $vars['form_markup'] = drupal_render($vars['form']);
}

Finally, my user-register.tpl.php file looks like this:

<h2>Hello world</h2>
<!-- Let's print the form's XHTML -->
<?php print $form_markup; ?>

But when I go to the http://www.MyDomian.com/user, all I get is a blank page. Does anyone have any idea what I'm doing wrong?

Thanks for you help in advance!

adpo’s picture

change this
$hooks['user_register'] => array( 'arguments' => array('form' => NULL)
to
$hooks['user_register'] = array( 'arguments' => array('form' => NULL)

akalata’s picture

Status: Active » Closed (fixed)