A few things..

Firstly, creating a new theme specific variables function doesn't get picked up. I tried with "garland_preprocess_page()". Cleared registry and it still won't see it.

Preprocess functions for the 'node' hook have two entries for "template_preprocess_node". I'd guess that it's running twice for each node.

Adding a variables function i.e. "phptemplate_preprocess_HOOK()" *without* a .tpl.php file in the themes directory is ignored. Maybe not a big deal but I think this would cause less confusion. Let themers keep a .tpl file inside the module folders if they wish but still have the ability to alter $variables.

Lastly, there should be a clear and easy way to keep the registry un-cached for theme dev. What would be the best way to do this. Documenting "drupal_rebuild_theme_registry()" to be placed inside the theme or should there be a checkbox in the performance section? --either way, I'm sure people will get a bit confused about this.

Comments

merlinofchaos’s picture

I'll look more into registering preprocess functions even without a template, but it looks like it might be a little bit difficult, due to when discovery of that is actually made.

I think the general consensus is that devel.module could very easily have a setting to clear the cache or certain caches during hook_boot or whatnot, and that's definitely where such a setting should go.

dvessel’s picture

The issue with "template_preprocess_node" being registered twice was fixed with this patch for cleaning the default page.tpl.php. An unlikely place. http://drupal.org/node/163723

Theme specific preprocess variable functions still don't work. Tried with Garland.. page, node, profile_block..

I'll look more into registering preprocess functions even without a template, but it looks like it might be a little bit difficult, due to when discovery of that is actually made.

If it ends up being too troublesome, maybe try for D7? It's not critical or anything. I think in most cases, editing variables would lead to altering the template itself.

Another issue I found with trying to convert search.module to templates is that theming forms is completely broke or I missed something completely. The existing theme functions for forms aren't even being used so I'm stuck with that. The issue is waiting here: http://drupal.org/node/164032

merlinofchaos’s picture

Theming forms works fine, but they still have to be registered. Which is a little frustrating, since you can't just create a theme_blahblahblahform, you have to register it and clear the cache.

I haven't figured out a decent solution for that. You can still override them, but that'll mean implementing hook_theme() in your theme and creating an override. That's something we'll need to document. "Overriding unregistered theme functions".

dvessel’s picture

It looks like there's another problem with that. Setting up a default "template_preprocess_search_theme_form" function and registering it still prevents it from being called.

I checked the registry and it's present but wherever it's being calling has to change too.

On top of that, forms use drupal_render(). Multiple preprocess functions don't seem to fit well with it. Which one does the rendering? template_preprocess or the theme trying to override it.?

dvessel’s picture

bah, never mind about how it's called. There's a bug:


function search_forms() {
  $forms['search_theme_form']= array(
    'callback' => 'search_box',
    'callback arguments' => array('search_theme_form'),
  );
  $forms['search_block_form']= array(
    'callback' => 'search_box',
    'callback arguments' => array('search_block_form'),
  );
  return $forms;
}


function search_box(&$form_state, $form_id) {
  // Use search_keys instead of keys to avoid ID conflicts with the search block.
  $form[$form_id .'_keys'] = array(
    '#type' => 'textfield',
    '#size' => 15,
    '#default_value' => '',
    '#attributes' => array('title' => t('Enter the terms you wish to search for.')),
  );
  $form['submit'] = array('#type' => 'submit', '#value' => t('Search'));
  // Always go to the search page since the search form is not guaranteed to be
  // on every page.
  $form['#action'] = url('search/node');
  $form['#submit'][] = 'search_box_form_submit';
  $form['#validate'][] = 'search_box_form_validate';
  $form['#theme'] = 'search_box_form';

  return $form;
}

callback arguments don't match.

Sorry to bring this up so late, I'm just realizing this now after working wit hit.

dvessel’s picture

Priority: Normal » Critical

Marking as critical due to this issue:

Firstly, creating a new theme specific variables function doesn't get picked up. I tried with "garland_preprocess_page()". Cleared registry and it still won't see it.

Also placed a separate issue for the search form. http://drupal.org/node/164351

dvessel’s picture

Here's another one.

Inside drupal_discover_template(), path_to_theme() points into the modules folder if the variable function that suggests the template is inside the module folder.

This doesn't happen with suggestions from 'page' or 'node'. Only difference being that they are inside includes/theme.inc.

dvessel’s picture

That had nothing to do with the registry. Made a separate issue here. http://drupal.org/node/165343

dvessel’s picture

StatusFileSize
new1.73 KB

This is for the issue I mentioned in #6.

_theme_process_registry creates both engine and *theme* specific variable functions.

dvessel’s picture

Status: Active » Needs review
dvessel’s picture

Title: theme registry quirky behavior. » Allow theme engine to register theme variable functions.

More appropriate title.

This only works when a template file exists inside the folder. Merlinofchaos informed me that without the template in the themes folder, it makes it difficult to discover but that's not critical.

merlinofchaos’s picture

Status: Needs review » Reviewed & tested by the community

Ok. This is important, and this works.

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Needs work

We have done quite some modification around this part of the code in the last days AFAIR. This looks like it needs a rethink/reroll/reposition.

dvessel’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new1.36 KB

Here it is..

dvessel’s picture

This really needs to be reviewed. Without it, themers will have to do more work to register these manually.

dvessel’s picture

Uh, I mean commited. :)

dries’s picture

Status: Reviewed & tested by the community » Fixed

Yep, this is truly important to get right. Committed it to CVS HEAD. Thanks for the hard work.

dvessel’s picture

Status: Fixed » Reviewed & tested by the community
StatusFileSize
new607 bytes

Not sure how I didn't catch this. It was working fine before but with all the changes in HEAD, it's causing a bunch of duplicate preprocess functions causing doubles of each region.

The way the array was setup just kept building up duplicates. Sorry bout that.

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, committed.

Anonymous’s picture

Status: Fixed » Closed (fixed)