Actually, all vocabularies are shown in the first drop down list. Should be better to see only those assigned to selected content-types in the admin section.

To do this, in linktocontent_node.module, in the _linktocontent_node_get_categories function, replace :

  foreach ($containers as $item) {
    $obj = new StdClass;
    $obj->vid = $item->vid;
    $obj->tid = ($top ? $item->vid : $item->tid);
    $obj->title = (trim($item->name));
    $results[] = $obj;
 } // end foreach
return $results;

by

  $status = variable_get('linktocontent_node_content_types', array());
  foreach ($containers as $item) {
    $obj = new StdClass;
	if (isVocabularyForContainer($item->nodes,$status)) {
		$obj->vid = $item->vid;
		$obj->tid = ($top ? $item->vid : $item->tid);
		$obj->title = (trim($item->name));
		$results[] = $obj;
	}
  } // end foreach
  return $results;

and add the function as below :

function isVocabularyForContainer($container, $vocabularies) {
	$nopresent = array_diff($vocabularies, $container);
	return (! (count($nopresent) == count($vocabularies)));
}

Is this feature could be include in the next patch ?

Comments

stborchert’s picture

Assigned: Unassigned » stborchert

Hi Marc.
Thanks for your feedback.
I hope to be able to create a new version (5.2.x) within the next weeks (or finally start with coding on it).
This feature will be in it definitely.

thanks again,

Stefan

stborchert’s picture

Version: 6.x-2.x-dev » 5.x-2.x-dev
Category: feature » task

moved task to new development version

webrascal’s picture

The suggestion works great but needs a tweak.

In the loop of the 'containers' it assumes it's always dealing with a vocabulary and not the final terms.

This means when you're at the lowest level (terms) you're testing in isVocabularyForContainer returns errors as terms node does not have a nodes attribute.

I recommend this solution:


  $status = variable_get('linktocontent_node_content_types', array());
  foreach ($containers as $item) {
    $obj = new StdClass;
    if ($container > 0 || isVocabularyForContainer($item->nodes,$status)) {
        $obj->vid = $item->vid;
        $obj->tid = ($top ? $item->vid : $item->tid);
        $obj->title = (trim($item->name));
        $results[] = $obj;
    }
  } // end foreach
  return $results;