简体   繁体   English

如何在显示Drupal分类的视图中添加自定义链接

[英]How to add custom links in views showing taxonomy in drupal

I had created a view where it shows taxonomy. 我创建了一个显示分类法的视图。 Now i want to put a href tag before the taxonomy name by programatically . 现在,我要通过编程将href标签放在分类名称之前。 What i have done is this 我所做的是这个

<?php
// $Id$

/**
 * @file
 * Museum
 */
function museum_views_pre_render(&$view) {
    if ($view->name == 'museumlist')
    {
     //var_dump($view);
     foreach ($view->result as $result) {
            $childern=taxonomy_get_children($result->tid);
         //var_dump($result);
      // Replace all empty fields with the dash '-' character.
     $result->taxonomy_term_data_name='<a href="google.com">'.$result->taxonomy_term_data_name.'</a>';
}
    }
}

So for example i want to link the taxonomy_term_data_name to google.com for example if it has no children. 因此,例如,如果没有子项,我想将taxonomy_term_data_name链接到google.com。 How to achieve this 如何做到这一点

I would go for this from view's template file. 我将从视图的模板文件中获取该信息。 In Advanced / Theme information check which view template you have to change and even get it's default content there. 在高级/主题信息中,检查您必须更改的视图模板,甚至在那里获取其默认内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM