Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get around taxonomy paradox?

I am using the "taxonomy display" module. I use to so that I can sort my taxonomy terms by title, instead of by ID, as it does by default. However, I also created a taxonomy template called:

taxonomy-term--product_literature_category.tpl.php

If I enable the "taxonomy display" module and override the taxonomy view for this path:

/taxonomy/term/%

... it also overrides the template I specified above. It would make more sense that the order would be to take my custom template override the module. But it doesn't seem to work that way. But if I disable "taxonomy display", it again takes my template into account.

I have two choices:

  1. Enable "taxonomy display" and find a way to override taxonomy-term--product_literature_category.tpl.php
  2. Disable "taxonomy display" and find a way to sort taxonomy terms by my own custom sorting parameters.

I would imagine 1 being difficult (because it doesn't make much sense to use two templates for the same thing). That is why I'm leaning towards an easier way to sort taxonomy views by default, or some other way to specify the ordering of taxonomy terms.

Does anyone know how to do this?

UPDATE

Right now I am going to settle with figuring out a hook to change the sorting of taxonomy terms via a module. That way I can override the sorting for only specific vocabularies. Any pointers to nudge me in that direction would be highly appreciated?

UPDATE 2

I've created teaser_sorter.module and added this function:

function teaser_sorter_views_query_alter(&$view, &$query)
{
    print '<pre>'; print_r($view); print_r($query); die();
}

I also made sure my module supports views:

function teaser_sorter_views_api() {
   return array(
      'api' => 3,
   );
}

I can't get it to ever reach my "die". In other words, it's never called. In fact, I also tried overriding "hook_views_pre_execute", but that doesn't ever get called either.

Any ideas?

like image 986
coderama Avatar asked May 25 '15 16:05

coderama


1 Answers

 view :  <google-taxonomy-category class="googlecategoryselectiontool" field-name="goo_cat_id" cat-sel=""></google-taxonomy-category>


       "class" used for template setup so if I want to use any.tpl then I simply have to  write tplname. if no class value given then it will take default template.
"field-name" it will consist name of the request variable  which you want to set on checkbox. by default its value going to be "selected_value[]" if no value passed for it.
      "cat-sel" it will consist of data of which category need to be selected when html load. it will take value like <?php echo htmlspecialchars(json_encode($selected_value)); ?> in          
        which $selected_value  is the array of all category id which need to be selected. 
like image 116
Reena Mori Avatar answered Nov 09 '22 07:11

Reena Mori