Tinytax Block

Главные вкладки

Аватар пользователя h.p.geerdes h.p.geerdes 16 сентября 2008 в 15:37

Здравствуйте!

У меня есть 'меню', которое работает на Tinytax Block:
name = Tiny Taxonomy Browser;
version = "5.x-1.8";
link = http://drupal.org/node/260608

Там смысл такой: меню состоит из "Термин (циферка) иконка".
Жмёшь на Термин - меню раскрывается на подменю.
Жмёшь на иконку - она работает как ссылка и отправляет собственно на страницу с материалом.
Скрытие/раскрытие меню происходит посредством js.

Я хочу поменятьих работу с точность до наоборот, что бы было так:
Жмёшь на Термин - она работает как ссылка и отправляет собственно на страницу с материалом.
Жмёшь на иконку - меню раскрывается на подменю.

вот код функции друпала, которая управляет меню:

function _theme_tinytax_term_list_link($term, $vid, $used_terms){
  $class = 'tinytaxlink';
  if(in_array($term->tid,$used_terms)){
    $class .= 'used';
  }  
  $return_string = '">'.
  l(
    $term->name,
    'taxonomy/term/'.$term->tid,
    array(
      'class'=>$class,
      'title'=> t('Click to see the descendants of this name'),
      'onclick'=>"tinytaxalterroot('".url('tinytax/get/'.$term->tid,null,null,true)."');return false;"
    )
  );
  $num_children = 0;
  if(variable_get('tinytax-'.$vid.'-showchildren',1)){
    $num_children = count(taxonomy_get_children($term->tid, $vid));
  }
  if ($num_children>0){
    $return_string .=' <small>('.count(taxonomy_get_children($term->tid, $vid)).')</small>';
  }
  if (substr($term->tid,0,3)!='vid'){
    $return_string .= l(
      '<img src="'.url(drupal_get_path('module','tinytax')).'/images/plus.png'.'"/>',
      'taxonomy/term/'.$term->tid,
      array(
        'title'=> t('Click to see all content tagged with this name')
      ),
      null,
      null,
      null,
      TRUE
    );
  }
  $return_string .= '</p>';
  return $return_string;
}

вот код js:

// $Id: tinytax.js,v 1.5 2008/02/06 17:58:46 sdrycroft Exp $
function tinytaxalterroot(url){
  var tinytaxReturn = function (data) {
    var returnHtml = Drupal.parseJson(data);
    $('#tinytaxroot-'+returnHtml['vid']).html(returnHtml['html']);
    $('a.tinytaxlink').click(tinytaxalterroot);
  }
  $.get(url, null, tinytaxReturn);
  return false
}

Пробовал сам как-то решить эту траблу - у меня ничего не вышло Sad

Если кто знает решение проблемы, или направление, в котором двигаться - буду очень признателен!!
С меня СПАСИБО Wink

ps.модерам: если тему надо было разместить в другой ветке форума, сорри - размещайте

Комментарии

Аватар пользователя h.p.geerdes h.p.geerdes 16 сентября 2008 в 17:42

частично решил проблему так:
- перенёс некоторые поля из первого массива во второй:

function _theme_tinytax_term_list_link($term, $vid, $used_terms){
  $class = 'tinytaxlink';
  if(in_array($term->tid,$used_terms)){
    $class .= 'used';
  }  
  $return_string = '">'.
  l(
    $term->name,
    'taxonomy/term/'.$term->tid,
    array(
      'class'=>$class,
      'title'=> t('Click to see the descendants of this name'),
      'onclick'=>"tinytaxalterroot('".url('tinytax/get/'.$term->tid,null,null,true)."');return false;"
    )
  );
  $num_children = 0;
  if(variable_get('tinytax-'.$vid.'-showchildren',1)){
    $num_children = count(taxonomy_get_children($term->tid, $vid));
  }
  if ($num_children>0){
    $return_string .=' <small>('.count(taxonomy_get_children($term->tid, $vid)).')</small>';
  }
  if (substr($term->tid,0,3)!='vid'){
    $return_string .= l(
      '<img src="'.url(drupal_get_path('module','tinytax')).'/images/plus.png'.'"/>',
      'taxonomy/term/'.$term->tid,
      array(
        'title'=> t('Click to see all content tagged with this name')
      ),
      null,
      null,
      null,
      TRUE
    );
  }
  $return_string .= '</p>';
  return $return_string;
}

но появилась новая проблема:
- во главе меню стоит ссылка, которая при клике возвращала меню в исходное положение - сворачивала.
- а теперь эта ссылка ведет на страницу с материалом, которого не существует.. мне теперь нужно вернуть первому пункту меню исходную функциональность.

Аватар пользователя h.p.geerdes h.p.geerdes 18 сентября 2008 в 16:03

усё исправил))
вот код конечной функции:

function _theme_tinytax_term_list_link($term, $vid, $used_terms){
  $class = 'tinytaxlink';
  if(in_array($term->tid,$used_terms)){
    $class .= 'used';
  }  
  if (substr($term->tid,0,3)!='vid'){
    $return_string = '">'.
    l(
      $term->name,
      'taxonomy/term/'.$term->tid,
        array(
          'title'=> t('Click to see all content tagged with this name')
        )
    );
  }
  else {
    $return_string = '">'.
    l(
      $term->name,
      'taxonomy/term/'.$term->tid,
      array(
        'class'=>$class,
        'title'=> t('Click to see the descendants of this name'),
        'onclick'=>"tinytaxalterroot('".url('tinytax/get/'.$term->tid,null,null,true)."');return false;"
      )
    );
  }
  $num_children = 0;
  if(variable_get('tinytax-'.$vid.'-showchildren',1)){
    $num_children = count(taxonomy_get_children($term->tid, $vid));
  }
  if ($num_children>0){
    $return_string .=' <small>('.count(taxonomy_get_children($term->tid, $vid)).')</small>';
  }
  if (substr($term->tid,0,3)!='vid'){
    $return_string .= l(
      '<img src="'.url(drupal_get_path('module','tinytax')).'/images/plus.png'.'"/>',
      'taxonomy/term/'.$term->tid,
    array(
      'class'=>$class,
      'title'=> t('Click to see the descendants of this name'),
      'onclick'=>"tinytaxalterroot('".url('tinytax/get/'.$term->tid,null,null,true)."');return false;"
    ),
      null,
      null,
      null,
      TRUE
    );
  }
  $return_string .= '</p>';
  return $return_string;
}

если кому понадобится - юзайте))