How could I remove the string
"There is currently no content classified with this term."
from taxonomy term page.
I put in my template.php file following code (with Theme changed to my theme name) but it do nothing

function THEME_preprocess_node(&$variables, $hook) {
  if(isset($variables['page']['content']['system_main']['no_content'])) {
    unset($variables['page']['content']['system_main']['no_content']);
  }
}

I do not want to use String Overrides module or CSS just want to remove it from the page.

Comments

faseeh.abrar’s picture

Hi,

Are you overriding the default view of Taxonomy Term which comes with the Taxonomy module. If you are not than you can override that one and then set the No Resullt Behaviour

NexusStar’s picture

No, I do not use view for taxonomy term because it crashed Media Gallery layout, but am considering using again Views for Taxonomy Term.

Entering The Dip and trying to win over it.

apollonet’s picture

For Drupal 7, the right code is :

function THEME_preprocess_page(&$vars) {
  if(isset($vars['page']['content']['system_main']['no_content'])) {
    unset($vars['page']['content']['system_main']['no_content']);
  }
}
noizo’s picture

I'm adding this code to my template.php (its tb_methys)
So my template.php file lokks like that:

<?php
/**
 * @file
 * controls load theme.
 */
function tb_methys_preprocess_page(&$vars) {
  if(isset($vars['page']['content']['system_main']['no_content'])) {
    unset($vars['page']['content']['system_main']['no_content']);
  }
}
require_once drupal_get_path('theme', 'tb_methys') . '/inc/preprocess_functions.inc';

After saving, i'm receiving an error:

Fatal error: Cannot redeclare tb_methys_preprocess_page() (previously declared in /home/khomusi1/public_html/sites/all/themes/tb_methys/template.php:6) in /home/khomusi1/public_html/sites/all/themes/tb_methys/inc/preprocess_functions.inc on line 51

After looking at preprocess.function.inc, it looks like it allready have some overrides.

/**
 * Override or insert variables into the page template.
 *
 * @param $vars
 *   An array of variables to pass to the theme template.
 */
function tb_methys_preprocess_page(&$vars) {
  if (isset($vars['node'])) {
    if($vars['node']->type != 'page')
    {
      $result = db_select('node_type', NULL, array('fetch' => PDO::FETCH_ASSOC))
        ->fields('node_type', array('name'))
        ->condition('type', $vars['node']->type)
        ->execute()->fetchField();
      $vars['title'] = $result;
    }
  }
}

Please advise what to do.

jamix’s picture

Thanks apollonet, works like a charm.

leerempel’s picture

Works perfectly

DaveLindberg’s picture

Thanks NexusStar, this looks useful. I'm still learning the ropes here, can you specify where this code should be added?

NexusStar’s picture

You should put it in your template.php file for the active theme you are using and change THEME with the name of the theme

Entering The Dip and trying to win over it.

Bruno Vincent’s picture

In what file do I put this coded, this is for a Drupal 7 site, fall 2017