I'm using Taxonomy Grid Module for my taxonomy pages. One downside of this module is that it doesn't display term description. Now I want you to do just that.

As per the module's author advice (http://drupal.org/node/996238#comment-4198200) I can just override the theme_taxonomy_grid_title_link function.

function theme_taxonomy_grid_title_link($name,$term,$link){
  $output="";

  $output.=l($name, $link, array('attributes' => array('id' => "tg-text-".$term->tid)));

  return $output;
}

I'm okay with hacking core so please just post the overridden function here.

Post the solution here and how much your bounty is and let me know your (only) paypal. The first one to post a workable solution will get the bounty.

More info in module's issue queue - http://drupal.org/node/996238

Comments

nevets’s picture

You can place then in your themes template.php file

function YOURTHEMENAME_taxonomy_grid_title_link($name,$term,$link){
  $output="";

  $output.=l($name, $link, array('attributes' => array('id' => "tg-text-".$term->tid)));
  $output .= " $term->description";

  return $output;
}

Change YOURTHEMENAME to your themes actual name and it just tacks the description on after the link.

halloffame’s picture

Okay thanks for that but it didn't work the way I wanted. It inserts the description along with the children terms like this:

PARENT TERM PAGE

Child Term 1
(Description goes here)
---------------------
-------IMAGE--------
---------------------

Child Term 2
(Description goes here)
---------------------
-------IMAGE--------
--------------------

But what I really want is:

PARENT TERM PAGE
(Description goes here for the parent term and not on children)

Child Term 1
---------------------
-------IMAGE--------
---------------------

Child Term 2
---------------------
-------IMAGE--------
--------------------

Perhaps the theme_taxonomy_grid_show_children?

function theme_taxonomy_grid_show_children($children,$type="list"){
  $output="";
   
  switch ($type){

    case "div":
      $output.="<div class='tg_terms'>";
      foreach ($children as $term){
        $link=taxonomy_grid_get_associated_link($term);
        $output.=" ";
        $children2=taxonomy_get_children($term->tid);
        $output.=l($term->name, $link, array('attributes' => array('id' => "tg-text-".$term->tid)));
        if (count($children2)>0) $output.=theme('taxonomy_grid_show_children',$children2,"list");
      }
      $output.="</div>";
      break;
       
    case "list":
      $output.="<ul class='tg_terms'>";
      foreach ($children as $term){
        $link=taxonomy_grid_get_associated_link($term);
        $output.="<li>";
        $children2=taxonomy_get_children($term->tid);
        $output.=l($term->name, $link, array('attributes' => array('id' => "tg-text-".$term->tid)));
        if (count($children2)>0) $output.=theme('taxonomy_grid_show_children',$children2,"list");
        $output.="</li>";
      }
      $output.="</ul>";
      break;
    default:
      break;
  }

  return $output;
}
nevets’s picture

You could modify that function as

function YOURTHEMENAME_taxonomy_grid_show_children($children,$type="list", $level = 0){
  $output="";
  
  switch ($type){

    case "div":
      $output.="<div class='tg_terms'>";
      foreach ($children as $term){
        $link=taxonomy_grid_get_associated_link($term);
        $output.=" ";
        $children2=taxonomy_get_children($term->tid);
        $output.=l($term->name, $link, array('attributes' => array('id' => "tg-text-".$term->tid)));
        if ( $level == 0 ) {
            $output .= " $term->description";
       }
        if (count($children2)>0) $output.=theme('taxonomy_grid_show_children',$children2,"list", $level+1);
      }
      $output.="</div>";
      break;
      
    case "list":
      $output.="<ul class='tg_terms'>";
      foreach ($children as $term){
        $link=taxonomy_grid_get_associated_link($term);
        $output.="<li>";
        $children2=taxonomy_get_children($term->tid);
        $output.=l($term->name, $link, array('attributes' => array('id' => "tg-text-".$term->tid)));
        if ( $level == 0 ) {
            $output .= " $term->description";
       }
        if (count($children2)>0) $output.=theme('taxonomy_grid_show_children',$children2,"list", $level+1);
        $output.="</li>";
      }
      $output.="</ul>";
      break;
    default:
      break;
  }

  return $output;
}

and leave the other theme function alone.

halloffame’s picture

Still not the way I intend it to be... Looks like both functions won't do it as per module's author advice. Let me clarify..

On your first function this is what I'm getting:

(Viewing parent term page)

PARENT TERM TITLE HERE

Child Term 1
(Description goes here)
---------------------
-------IMAGE--------
---------------------
   Child Term 1-1
   Child Term 1-2
   Child Term 1-3


Child Term 2
(Description goes here)
---------------------
-------IMAGE--------
--------------------
   Child Term 2-1
   Child Term 2-2
   Child Term 2-3

..And for your second function this is what I'm getting:

(Viewing parent term page)

PARENT TERM TITLE HERE

Child Term 1
---------------------
-------IMAGE--------
---------------------
   Child Term 1-1 (Description goes here)
   Child Term 1-2 (Description goes here)
   Child Term 1-3 (Description goes here)


Child Term 2
---------------------
-------IMAGE--------
--------------------
   Child Term 2-1 (Description goes here)
   Child Term 2-2 (Description goes here)
   Child Term 2-3 (Description goes here)

But then again... This is what I'm trying to achieve.

(Viewing parent term page)

PARENT TERM TITLE HERE
(Description goes here and not anywhere else)

Child Term 1
---------------------
-------IMAGE--------
---------------------
   Child Term 1-1 
   Child Term 1-2
   Child Term 1-3


Child Term 2
---------------------
-------IMAGE--------
--------------------
   Child Term 2-1
   Child Term 2-2
   Child Term 2-3

Perhaps you could take a peak at the module? Though I would also like to point out that 'page-taxonomy_grid.tpl.php' template is available for use. I was able to insert static text into the parent term page the way I want it but no luck with the term description.

I was able to use the following on the normal taxonomy template (page-taxonomy.tpl.php) and print term description but not on page-taxonomy_grid.tpl.php

<?php $current = taxonomy_get_term(arg(2)); ?>
<?php if ($current): ?>
    <div class="taxonomy-description">
        <?php echo $current->description; ?>
    </div>
<?php endif; ?> 

Can we have the same thing for page-taxonomy_grid.tpl.php?

halloffame’s picture

Looks like @nevets is out... So any takers?

Is there any way we can make this work on page-taxonomy_grid.tpl.php

<?php $current = taxonomy_get_term(arg(2)); ?>
<?php if ($current): ?>
    <div class="taxonomy-description">
        <?php echo $current->description; ?>
    </div>
<?php endif; ?>
sagar ramgade’s picture

Hi,

If you are willing to hack the code here's the solution for you :
Put the code below in taxonomy_grid.module under function taxonomy_grid_nav($tid = 0) (line no 134) on the second line after $output = '';

if($tid){
    $parent = taxonomy_get_term($tid);
    $output .= $parent->description;
  }

Hope that works.

Regards
Sagar

Acquia certified Developer, Back end and Front specialist
Need help? Please use my contact form

halloffame’s picture

@Sagar Ramgade it did the trick. Thanks. Post here or PM me your paypal.

sagar ramgade’s picture

Mailed you my paypal id, Hope you recieved it.

Acquia certified Developer, Back end and Front specialist
Need help? Please use my contact form

halloffame’s picture

Yep got it. Check your email...