When there is no content classified with term, I see a message at the term page: "There is currently no content classified with this term."

I need to surpress thiss message correctly, drupal-way.

Of course, I can delete 3 lines of code in taxonomy.pages.inc, I can translate this message to the empty string (non-English site) etc. But maybe someone could help?

Comments

conspirolog’s picture

Thanks for the reply, I've made this in theme_preprocess():

	if(isset($variables['page']['content']['system_main']['no_content']))
	{
		unset($variables['page']['content']['system_main']['no_content']);
	}
iaugur’s picture

Another way of doing this is to add a class to the paragraph surrounding the message. This has advantages over removing the message completely
In your template.php:

function YOURTHEME_process_page(&$variables) {
  if(isset($variables['page']['content']['system_main']['no_content'])) {
    $variables['page']['content']['system_main']['no_content']['#prefix'] = '<p class="empty-term">' ;
  }
}

You can use string overrides or the translation system to override the message.
Or provide a new message by overwriting the default markup:

function YOURTHEME_process_page(&$variables) {
  if(isset($variables['page']['content']['system_main']['no_content'])) {
    $variables['page']['content']['system_main']['no_content']['#prefix'] = '<p class="no-content-msg">' ;
    $variables['page']['content']['system_main']['no_content']['#markup'] = t('There are no items on this category') ;
  }
}

Bear in mind that you might want to generalise this for all no content messages (as above) or make it specific to taxonomy term pages by checking that you are on the taxonomy term page.

George Boobyer
www.blue-bag.com

summit’s picture

Hi,
There is module now for it: http://drupal.org/project/taxonomy_display

Greetings, Martijn