Problem/Motivation
Currently it is not possible to disallow terms to have children. It would be really interesting, though.
Proposed resolution
Allow to set "Maximum ancestor depth" to 0 and act accordingly.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | taxonomy_max_depth_disable_hierarchy-3092689-3.patch | 6.28 KB | duaelfr |
| #3 | interdiff.3092689.2.3.txt | 601 bytes | duaelfr |
Comments
Comment #2
duaelfrHere is the patch.
You might want to extend test coverage :)
Comment #3
duaelfrI accidentally reversed a condition and I forgot to hide the parent field in the term edit form.
Comment #4
dmitriy.trt commentedThanks a lot for working on this feature! It would be awesome to add this into the first stable release! A few points that should be improved on the patch are below.
1) Tests for existing code fail with the patch and they should be fixed. Functional tests should be written for this feature as well, probably it is possible to just add them to existing ones.
2) It would be very nice to keep the same interfaces and meaning of the values they return. For example:
With the patch applied, we're gonna break this interface, as meaning of the return value changes. Could we instead keep it as it is now? NULL could mean no limit and 0 could mean that hierarchy must be completely disabled. This way you don't need constant for a special unlimited value and still could distinguish them using
isset($max_depth)and$max_depth === 0. We could use empty string as unlimited value on the vocabulary form where user edits the limit.3) When you need to reference a class constant from a different class, it's nice to define a constant in the class that's gonna use it, reference the original one and then use it as
static::CONSTANT_NAME. This way it's really easy for a child class to change the constant value. But if you reference it directly asOtherClass::CONSTANT_NAME, then it's not possible in a child class to override it.For example, this one doesn't allow us to change the constant value in a child class:
But this one does:
Comment #5
dmitriy.trt commentedComment #7
dmitriy.trt commentedCommitted with changes.
Comment #8
duaelfrThanks!
I'm sorry I wasn't able to follow up on this. I'm glad you had more time than me.