Download & Extend

Inherit parent terms settings?

Project:Taxonomy Views Integrator
Version:7.x-1.x-dev
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

Is it possible for child terms to inherit the parent terms views settings as opposed to having to set child terms individually to match the parent?

I assumed this is the way TVI works, but it seems that if terms need to be set individually. This could be time consuming with many terms and there is an administration overhead if we give clients access to create new terms - many clients wouldn't want to have to learn about 'views' either?

Many thanks

Comments

#1

** bumping **

#2

+1 Subscribing

#3

+1

#4

Version:6.x-1.x-dev» 7.x-1.x-dev

I will try to do so on the 7.x branch

#5

Here is a patch !

Disclaimer
Tired to juggle with a lot of versions of this module, I decided to start from my already patched version.
I will provide two patch files, see the following section to know which you can use.

How to use it
* If you are currently using the latest dev version of TVI unpatched, use the tvi-inheritance-1073846-5.patch file.
* If you already patched your module with this patch, use the tvi-inheritance-increment-1073846-5.patch file.

How it works
This patch adds a new checkbox in the terms settings form.
When you are viewing a term page the module will check the following :
- if the term has its own settings, use them
- if not, loop on ancestors until finding a parent which has its own settings and be sure they are set as inheritables
- if no parent has its own settings or if none are inheritables, take the vocabulary settings

Example

Settings

Vocabulary : categories (view1)
Terms :

  • T 1 (view 2, inheritable)
    • T 1.1 (view 3, not inheritable)
      • T 1.1.1 (no settings)
    • T 1.2 (view 4, inheritable)
      • T 1.2.1 (no settings)
    • T 1.3 (no settings)
  • T 2 (no settings)

Results

  • T 1 (view 2 from itself)
    • T 1.1 (view 3 from itself)
      • T 1.1.1 (view 2 from T 1)
    • T 1.2 (view 4 from itself)
      • T 1.2.1 (view 4 from T 1.2)
    • T 1.3 (view 2 from T1)
  • T 2 (view 1 from vocabulary)
AttachmentSize
tvi-inheritance-1073846-5.patch 9.88 KB
tvi-inheritance-increment-1073846-5.patch 3.76 KB

#6

Status:active» closed (fixed)

This patch has been push to the 7.x branch.
It will be available in the next dev release.

#7

Status:closed (fixed)» needs review

We need to check if parent settings are inherited before we apply them.

AttachmentSize
tvi-inheritance-1073846-7.patch 686 bytes

#8

I think that your patch fix any real issue (but I may be mistaken).

Let's have an overview of the tvi_get_term_info() function :

First, check if the term have its own settings. (working)
If this settings does not exist or are disabled loop on term parents while parent settings are not enabled or not inheritables. (working)
If any parent have enabled and inheritable settings, take the vocabulary's. (working)
If the vocabulary have not enabled settings, take the module's default. (working)

More detail on the part you try to fix :

At first pass, $settings is unset or disabled (line 294) because it is the settings array from the term itself so when it comes to the while on line 300 it enters the loop.

The first loop pass take the first parent and load its settings the it checks the loop arguments again.
If the settings are set, enabled and inheritables, the loop will end. In the other cases it will load the parent's parent settings until there is no more parents left.

After the loop two possible cases :
- one parent's settings was enabled and inheritable (it will jump over lines 306 and 311 conditions)
- any parent had enabled and inheritable settings (we will try to load vocabulary's ones)

It put this issue back to the close state, please open a new one if needed.

#9

Status:needs review» closed (fixed)

#10

I don't want to open another issue because this one would be a duplicate I think. I'll do that if you insist :)

In my case I have set a view for the vocabulary and then I have top terms and sub terms. The top terms are set to use another view with iheritance switched off. So the child terms should use the vocabulary view.

The loop now checks my sub term does not have settings and loads parent (top term) into $settings. After that it does not check for top terms settings because it's over - the loop went only once and the settings is set to parent. So now I have top term as my $settings regardless of it iheritance state. What happens later doesn't matter.

Here's a modified patch removing notice error I had.

AttachmentSize
tvi-inheritance-1073846-10.patch 723 bytes

#11

Status:closed (fixed)» fixed

Ok I finally got it ! Sorry but I did not acheive to see where it was stuck.
I rewrited a bit your patch to fit my own code philosophy but thank you very much for this.

The attached patch is part of the #1day1patch initiative and has been commited to the 7.x branch.

AttachmentSize
tvi-fix-inheritance-chain-1073846-11.patch 616 bytes

#12

Well I'm very happy I wasn't wasting your time. I think your module is super handy with inheritance and this patch is crucial for the functionality:) One last thing: checking if isset($settings->inheritance) is needed. When parent term does not have views override enabled it will result in error notice.

#13

Is your last comment related to this issue ? #1899604: Notice: Undefined property: stdClass::$inherit in tvi_get_term_info() (linea 309 di /sites/all/modules/tvi/tvi.module)
If yes, it should be fixed by running updates on your site.

#14

Yes that's it! Thank you for quick replies! The issue is definitely closed now:)

#15

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

nobody click here