I have an issue: I want only add subterm on the second level of a category only.
I have the vocab with sports generally in the first level (football) and user can create subterm below this term (eg. futsal, indoor soccer) but I do not want a subterm before futsal. I want allow only 2 level hierarchy - main terms and subterms .

With the original SHS behavior If I enable the create new term option then the user can add new term to the third level too. If I not allow this option then he can not able to add new subterm to the football term.

I developed a solution: you can allow the new term creation on the special levels. There is the shot of the field settings form:
add new term settings

What do you think would my solution be an usable feature?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Denes.Szabo’s picture

Status: Active » Needs review
FileSize
7.53 KB

I attached my patch.

decibel.places’s picture

Patch in #1 failed one chunk:

patching file js/shs.js
Hunk #1 succeeded at 51 (offset 7 lines).
Hunk #2 succeeded at 61 (offset 7 lines).
Hunk #3 succeeded at 73 (offset 7 lines).
Hunk #4 succeeded at 94 (offset 7 lines).
Hunk #5 succeeded at 122 (offset 7 lines).
Hunk #6 FAILED at 127.
Hunk #7 succeeded at 166 (offset 7 lines).
Hunk #8 succeeded at 369 (offset 30 lines).
Hunk #9 succeeded at 447 (offset 30 lines).
1 out of 9 hunks FAILED -- saving rejects to file js/shs.js.rej
patching file shs.module

rerolled and applied to 7.x-1.x from git

One problem, though is that there is a nagging third level eunich that cannot be set but displays. My settings to allow adding a term on the second level, and stop there. First row select shown expanded with only option "none"

third level none

[edit]

wellz I hid it with CSS .shs-select-level-3 {display:none!important}

pinkonomy’s picture

@decibel.places: Hi ,I saw the image you have attached,have you manages to show all 3 levels from the beginning?If yes,how did you do that?
thanks

decibel.places’s picture

@pinkonomy do you mean how did I capture the -None- with the orange bg as the dropdown of the 3rd level?

I think I was using the Linux Shutter app. You should also be able to capture the screen on a PC with the PrtScn button. Or on Mac Apple key ⌘ + Shift + 3

Then I edited the full screen capture to the selection.

stBorchert’s picture

The patch is not needed since there is hook_shs_add_term_access() you may implement in a custom module to achieve this feature.

Example:

<?php
/**
 * Implements hook_shs_add_term_access().
 */
function shs_access_shs_add_term_access($vid, $parent, $account) {
  // Prevent creation of new childs of term 3 and on first level.
  if ($parent == 3 || $parent == 0) {
    return FALSE;
  }
  return TRUE;
}
?>
stBorchert’s picture

Issue summary: View changes
Status: Needs review » Closed (works as designed)
kitikonti’s picture

Related issues: +#2099011: New levels limit
ShaneOnABike’s picture

I agree that adding this into the system would be super awesome but the API works great once you get it all configured properly.

ALTHOUGH I would say that the last select should really be hidden if there are no results.