i ran again into an issue. I added to my theme folder a page-node-add.tpl.php to make special changes to the page. After this changes I was surprised that my dialog page presented me the template of the page-node-add.tpl.php file instead of the jquery_ui_dialog-page.tpl.php. So I made a look with the theme developer and found out that my preprocess function was called correctly and also the suggested jquery_ui_dialog-page.tpl.php was inside, but the sorting was in my case that the page-node-add.tpl.php was the last one in the array and has been delivered. I have been taken a look some days ago into the jquery_update module and saw there some interesting sugggestion to order the preprocess of the theme registry. I made some changes to your code and this problem of the wrong delivered template was fixed.

Maybe you can take a look at the changes and include these in your next update to prevent that this will happen to others who use your module..

function jquery_ui_dialog_theme_registry_alter(&$theme_registry) {
  if (isset($theme_registry['page']) && isset($theme_registry['page']['theme paths'])) {
    $module_path = drupal_get_path('module', 'jquery_ui_dialog');
    array_unshift($theme_registry['page']['theme paths'], $module_path);
    // See if our preprocess function is loaded, if so remove it.
    if ($key = array_search('jquery_ui_dialog_pre_preprocess_page', $theme_registry['page']['preprocess functions'])) {
      unset($theme_registry['page']['preprocess functions'][$key]);
    }
    $theme_registry['page']['preprocess functions'][] = 'jquery_ui_dialog_pre_preprocess_page';
  } 
}

It just removes the preprocess function and add it to the end that's it.

Comments

broncomania’s picture

Correction, I made a mistake. It didn't work...?? So once again. Maybe I forgot to clear the registry.
I solved this problem now in this way.
I removed every template suggestion and just add the jquery template. This is really working for me.

function jquery_ui_dialog_preprocess_page(&$variables) {
  if (!empty($GLOBALS['jquery_ui_dialog_page_template'])) {
    //if (!isset($variables['template_files'])) {
      $variables['template_files'] = array();
    //}
    array_unshift($variables['template_files'], 'jquery_ui_dialog-page');

    if(variable_get('jquery_ui_dialog_default_css', 0) != 0 ) {
      $m = drupal_get_path('module','jquery_ui_dialog');
      drupal_add_css($m.'/css/jquery_ui_dialog.default.css');
    }
  }
}

I just commentet the template check out and cleared every suggestion by the core and every other module and add only the jquery dialog template. Is there a better way ?