Added a new tool for selecting taxonomy terms

I added a new tool to aid in selecting taxonomy terms.
It appears as a link in a block positioned in the right side bar on edit pages.

Screen shot

A new option is available in the right sidebar: "Suggest keywords" containing one link: Highlight Terms.

Upon clicking the Highlight terms link a script searches the body of the node and does two things:

  1. Highlight taxonomy terms found in the body

    Screen shot

    Now the terms that were found in the body of the document have been highlighted.

  2. Produce a word cloud with the left over terms:

    Screen shot

    Here are the left over terms. Ones that were not highlighted. Next to the term name is the number of occurrences in the document.

The terms in the cloud are sorted by frequency of occurrence (most to least) and sized accordingly. They also have the number of occurrences in parenthesis next to the term.

If the user clicks a term a script populates the term in the “Enter New Tags” field. Separating any existing terms in the field with a comma.

I also added some code to slide the tool block down the right sidebar to be level with the taxonomy term section:

Screen shot

Here you can see the tax. section and the tool link are the same positioned the same.

I don’t think the method I used to position this block is ideal but it get’s the job done for now.

Back end info:
For now this code is split between a centrally located js file and a manually created block.
I’ve started creating a module that houses all of this code and creates the block but I wanted to get this working quick.
Here’s the module code:

<h2>Suggest Keywords</h2>
<a href="#">Highlight Terms</a>

&lt;?php
$suggest_terms_tax_super_select_js = &lt;&lt;&lt;javascript
Drupal.behaviors.suggest_terms_tax_super_select = function (context) {
	if(typeof($(&#039;#edit-taxonomy-tags-6&#039;).offset())!==&#039;undefined&#039;){
		taxTags6Top=($(&#039;#edit-taxonomy-tags-6&#039;).offset().top+140);
		$(&#039;#block-block-20&#039;).css({&#039;position&#039;:&#039;absolute&#039;,&#039;top&#039;:taxTags6Top+&#039;px&#039;});
		void(&#039; &#039;);
	}
}
JAVASCRIPT;
drupal_add_js($suggest_terms_tax_super_select_js, &#039;inline&#039;);

It's currently set up to show display on any page with */edit* in the url

Leave a Comment