【问题标题】:How to get around taxonomy paradox?如何解决分类悖论?
【发布时间】:2015-05-25 16:33:54
【问题描述】:

我正在使用“taxonomy display”模块。我使用 to 以便我可以按标题而不是按 ID 对分类术语进行排序,就像默认情况下那样。但是,我还创建了一个分类模板,名为:

taxonomy-term--product_literature_category.tpl.php

如果我启用“taxonomy display”模块并覆盖此路径的分类视图:

/taxonomy/term/%

... 它还覆盖了我上面指定的模板。顺序是让我的自定义模板覆盖模块会更有意义。但它似乎不是那样工作的。但如果我禁用“分类显示”,它会再次考虑我的模板。

我有两个选择:

  1. 启用“分类显示”并找到一种方法来覆盖分类术语--product_literature_category.tpl.php
  2. 禁用“分类显示”并找到一种方法,通过我自己的自定义排序参数对分类术语进行排序。

我认为 1 很困难(因为对同一件事使用两个模板没有多大意义)。这就是为什么我倾向于使用一种更简单的方法来默认对分类视图进行排序,或者采用其他方式来指定分类术语的顺序。

有人知道怎么做吗?

更新

现在,我将通过一个模块找出一个钩子来更改分类术语的排序。这样我就可以只覆盖特定词汇的排序。任何可以将我推向那个方向的指针将不胜感激?

更新 2

我创建了 teaser_sorter.module 并添加了这个功能:

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

我还确保我的模块支持视图:

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

我无法让它到达我的“死”。换句话说,它从来没有被调用过。事实上,我也尝试过覆盖“hook_views_pre_execute”,但也没有被调用。

有什么想法吗?

【问题讨论】:

  • 回复:更新 2 - 很抱歉问这个问题,但检查您的自定义模块是否已启用。或者,您可以浏览这篇文章,看看您是否遗漏了什么。 tylerfrankenstein.com/code/…
  • 它肯定是启用的。我会假设我需要从一个新的 drupal 安装开始并摆弄?
  • 你试过Devel吗?你不需要那个die
  • 这是一个老问题,但是没有提到在 settings.php 中添加它可以指示正在使用/应该覆盖哪个模板文件 $conf['theme_debug'] = TRUE; drupal.org/docs/7/theming/overriding-themable-output/…

标签: drupal-7 views taxonomy


【解决方案1】:
 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. 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-14
    • 2011-12-02
    • 2014-07-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多