filter by categories
at 2015-12-10 10:47:00.
if you are using drupal 7 you and you are using taxonomy to categories your content, on the admin tab you may want to be able to filter your corrent content by categories like you can on joomla.
that is just few lines of code that you can add.
to the file /modules/node/node.admin.inc on the line 134 you can change it like this(color one is the new lines that you should add)
and on the line 109
and for the file /modules/taxonomy/taxonomy.module at the line 2012
that is just few lines of code that you can add.
to the file /modules/node/node.admin.inc on the line 134 you can change it like this(color one is the new lines that you should add)
function node_build_filter_query(SelectQueryInterface $query) { // Build query $filter_data = isset($_SESSION['node_overview_filter']) ? $_SESSION['node_overview_filter'] : array(); foreach ($filter_data as $index => $filter) { list($key, $value) = $filter; switch ($key) { case 'term': $alias = $query->join('taxonomy_index', 'ti', "n.nid = %alias.nid"); $query->condition($alias . '.tid', $value); break; case 'status': // Note: no exploitable hole as $key/$value have already been checked when submitted list($key, $value) = explode('-', $value, 2); case 'type': case 'language': $query->condition('n.' . $key, $value); break; } } }
and on the line 109
if ($languages = module_invoke('locale', 'language_list')) { $languages = array(LANGUAGE_NONE => t('Language neutral')) + $languages; $filters['language'] = array( 'title' => t('language'), 'options' => array( '[any]' => t('any'), ) + $languages, ); } // The taxonomy filter if ($taxonomy = module_invoke('taxonomy', 'form_all')) { $filters['term'] = array( 'title' => t('category'), 'options' => array('[any]' => t('any')) + $taxonomy ); } return $filters; }
and for the file /modules/taxonomy/taxonomy.module at the line 2012
function taxonomy_taxonomy_term_delete($term) { if (variable_get('taxonomy_maintain_index_table', TRUE)) { // Clean up the {taxonomy_index} table when terms are deleted. db_delete('taxonomy_index')->condition('tid', $term->tid)->execute(); } } // new lines function taxonomy_form_all() { $vocabularies = taxonomy_get_vocabularies(); $options = array(); foreach ($vocabularies as $vid => $vocabulary) { $tree = taxonomy_get_tree($vid); if ($tree && (count($tree) > 0)) { $options[$vocabulary->name] = array(); foreach ($tree as $term) { $options[$vocabulary->name][$term->tid] = str_repeat('-', $term->depth) . $term->name; } } } return $options; }