When I try to override one the tpl.php files in filedepot/theme in my theme folder, the overridden file is not taken into account.
Anyone else encountered this, or knows a way how to fix this?

Sven

Comments

blainelang’s picture

Can you be more specific - what theme file where you trying to over-ride and how?

svendecabooter’s picture

Sure... I tried to override activefolder_admin.tpl.php.
I put a file named like that in my theme folder, copied the HTML from the original activefolder_admin.tpl.php file and adapted it.
After doing so the folder administration page would no longer show up...

blainelang’s picture

Status: Active » Postponed (maintainer needs more info)

Spent time on this one but no solution yet. There is a core D6 issue #279573 which it would appear is the cause and preventing the template file over-ride.

A workaround that I read in that issue, is that you have to copy over the parent template as well and in my case, that was the main theme file page.tpl.php which I did, clear cache and still no joy.

BTW: I have made a change in CVS as the naming of the modules main template file as page.tpl.php was a very bad idea and now it's called filedepot-mainpage.tpl.php.

I am changing the issue status to postponed for now and will spend more time on it, if anyone has some suggestions or can confirm the source of the issue.

sambc’s picture

I'm not seeing any change when I copy filedepot-mainpage.tpl.php over to my theme directory and edit it; I've cleared the cache, force-refreshed the page, and no change.

If it helps, I'm trying to slightly tweak the appearance of the toolbar, as it goes rather wonky in the space I have for it, which appears to be to do with a larger text size than expected (or something like that) - the search box overspills its width, appears to be positioned relative to something other than the toolbar, and so on - the toolbar ends up crowded because of the fixed-width of elements, you get the idea. The 'simple' fix I thought would be to theme it with a template, but the template doesn't seem to get picked up. Theming Views by the same mechanism didn't need me to do anything but copy/rename/edit the template file...

nibo’s picture

Hi,

I had the same issue in the D7 dev version.

A quick and dirty solution was to create a module, copy the templates I wanted to override and use Drupal's theme_registry_alter() hook:

/**
 * Implements hook_theme_registry_alter().
 */
function mymodule_theme_registry_alter(&$theme_registry) {

	$path = drupal_get_path('module','mymodule');

	$theme_registry['filedepot_filelisting']['template'] = $path.'/theme/filelisting_record';
	$theme_registry['filedepot_filelisting']['theme path'] = $path;

	$theme_registry['filedepot_header']['template'] = $path.'/theme/filelistingheader';
	$theme_registry['filedepot_header']['theme path'] = $path;

        // ... add here all other templates you want to override

}
blainelang’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

Thanks Nikolay for your posted solution.

beefheartfan’s picture

If you want to override all the filedepot templates with your helper module without hard-coding every single template (like #5 above) you could use code like this:

/**
* Implements hook_theme_registry_alter().
*/
function mymodule_theme_registry_alter(&$theme_registry) {
	// Get the path of the filedepot module.
	$original_path = drupal_get_path('module','filedepot');

	// Get the path of this module.
	$new_path = drupal_get_path('module','mymodule');
	
	// Loop through each item in the theme registry.
	foreach ($theme_registry as $key => $value) {
		// Check to see if this is a filedepot registry item.
		if (strncmp($key, 'filedepot_', 10) == 0) {
			// Check to make sure this filedepot item contains a template.
			if (array_key_exists('template', $theme_registry[$key])) {
				// Update the template location to be in this module instead of the filedepot module.
				$theme_registry[$key]['template'] = str_replace($original_path, $new_path, $theme_registry[$key]['template']);
				$theme_registry[$key]['theme path'] = $new_path;
			}
		}
	}
}
stefan.korn’s picture

Issue summary: View changes

As of D7 this is happening due to https://www.drupal.org/node/342350

Drupal is only picking up template files in theme folder if the template name matches the theme key (replacing underscores in key with hyphens in template). Since Filedepot is not using matching template names on all theme keys it happens for some templates that they will not get picked up in the theme.

A maybe leaner and cleaner solution using hook_theme_registry_alter to fix this could be like below. You would then also need to rename the template to match the new name when you copied it to the theme folder.

/**
* implemenents hook_theme_registry_alter()
*
*/
function yourmodule_theme_registry_alter(&$theme_registry)
{
  if(isset($theme_registry['filedepot_main_page']))
  {
    $theme_registry['filedepot_main_page']['template'] = 'filedepot-main-page';
  }
}