Hi,
This seemingly easy task has got me stumped. I posted elsewhere, but realised this belongs in the Views queue. I've been searching Drupal for an answer for ages with no luck so please forgive me if this is a duplicate...
Is it possible to have a View showing a terms siblings? (those that share the same parent)
The example is this: I have countries, regions and counties in my taxonomy:
England (country)
- South West (region)
-- Devon (county)
-- Somerset (county)
-- Cornwall (county)
-- Dorset (county)
- South East (region)
- East Of England (region)
etc etc etc
When On the ' Devon' term page, I want to display a View containing all the other counties in that region - eg a block containing links to Somerset, Cornwall and Dorset.
I have no problem displaying children through using relationships, and also can display parents without a problem - but am struggling with siblings.
This is for a 'term' style View.
Any help much appreciated,
Joe
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | termview.txt | 17.19 KB | fadgadget |
Comments
Comment #1
dawehnerAdd the parent relationship as always, and set the argument to the parent relationship
=> You get every taxonomy term which has the same parent(as the current one).
Comment #2
itangalo commentedAfter some discussion and practical exercises together with letharion, I would like to say that this is actually not possible with Views as it is now.
Some details can be found at http://drupal.org/node/1084338#comment-4181198
Comment #3
joecanti commentedHi,
This is indeed fixed - if you want a solution to this using panels check out the link above in #2.
Following Italgalo's helpful post, here's a brief summary of what I did:
- Made a View to return a list of terms depending on the argument.
- Made a second View to get the term ID from the URL
- Added second view as a context to the mini panel
- Also addled term:parent reationship context to the mini panel
- Then added first View to mini panel, adding Parent Term ID as a context
- Then placed this mini panel on the tax term pages
So now when I go to a term page, I see a list if it's siblings in the Panel sidebar.
Basically using a View to make the list, which gets it's argument through Panels context and from another View, which picks Term ID from the URL.
Cheers Itangalo for your help,
Joe
Comment #4
fadgadget commentedIll reopen this as the only solutions that are available are using page manager.
I think i managed to do this with Views 2 and Drupal 6. For the life of me i am unable to remember how i managed it. Ive been at it all day too. The original poster asks-
Thats the same for me. Im trying to create a block that displays whilst viewing a node. At the moment i can only display child terms and if a nodes term has no child term then my blocks wont show. I have the views to look for the term on the node.
Has anyone been able to work out if it is possible in Views without using Panels as much as i like Panels i have enough modules to be getting on with.
Thanks.
Comment #5
itangalo commented@fadgadget: If you managed to do this with Views 2, then you probably used the contextual filters that filters on taxonomy, and the one that modifies "term depth". I've never understood these completely, but I'd dig around there for a solution.
Another approach, which might be cleaner, is to code a new default value plugin, that fetches the parent term ID for the viewed term. With such a default value plugin in place, you'd need the following Views config:
1) A view listing country terms.
2) A relationship to the parent term.
3) A contextual filter, filtering on ID for the parent term.
4) A default value for the contextual filter, using the newly coded plugin.
5) Optionally, another contextual filter excluding the currently viewed country term (so "Devon" isn't listed again when viewing Devon).
Comment #6
fadgadget commentedThanks Intanglo. I actually reinstalled an old database of mine soemwehere and grabbed the old view off the site. I'll attach it here Its a bit of a mess is there is 2 or 3 blocks that need deleted from the view.
If folks are interested the Block settings Admin: kidterm30 block will show all child terms if you are on the parent term page. That works fine and as hoped. I found it somewhere on the net but had great problems recreating since. I hope this helps the original poster as it should resolve things for him.
The Admin: kidtermnode block is the block that im trying to show on a node. I was sure it used to work before but i cant seem to get it working again. I was hoping that it could show parent other children when viewing a node. I think. I'll take it showing anything remotely like the parent term i it has children or not.
attachment for Views 2 / D6
Comment #7
fadgadget commentedactually the Admin: kidtermnode block also works on a node if the term on the node has child terms. So in effect that block shows 'children terms of node term'. I can see it working here
http://onlinebanter.com/poker/one-where-we-all-win-loads-playing-poker
I think my problem is when viewing a node that has a term with no children.
http://onlinebanter.com/node/7300
I think if i reverse the term depth to pick up terms 'the other way' might have an effect. lets see....no i dont get to chose the argument with depth. I might be able to struggle on without showing 'sibling terms to the nodes term when viewing node' but if anyone can fill in a few gaps it would be much appreciated. thanks
Comment #8
studio-days commentedI HAVE A SOLUTION TO THIS! Sure, 4 years too late, but incase anybody else stumbles across this you can benefit from my hours of mucking about with this. This solution creates one single view, which will display Sibling Terms on a Parent Term Page, a Child Term Page and even a Node Page filed under a Child Term.
The trick is URLS, and the rest is simple.
Use PathAuto and Entity API (specifically Entity Token submodule) to create the following URL Patterns at admin/config/search/path/patterns:
Node ---> [node:your-term-field:parent]/[node:title]
Term ---> [term:parent]/[term:name]
Then in a Taxonomy Term View:
Fields ---> Taxonomy term: Name
Filter ---> Taxonomy term: Vocabulary (=Your Term Vocabulary)
Contextual Filter ---> Taxonomy Term: Parent term:
- Provide default value
- Raw value from URL
- Path component: 1
- Use path alias on
- Specify validation criteria on
- Validator: taxomony term
- Vocabulary: your term vocabulary
- Filter value type: Term name converted to Term ID
- Tansform dashes on
BANG!
Comment #9
BigBrother2010 commentedDo you have solution to show the same but in block(s) ?
Comment #10
justaman commentedfor this type of issue, I stop and ask myself: what entity am I trying to print?
For this, one common mistake is to try to paint the parent. When you do the contextual filtering, it will also filter out the parent's siblings, leaving you with the displaying element only.
Another common error, is to forget to create a row for each element. If we make this mistake, every element will display several times. (cardinal join)
So:
I am trying to print the node I am seeing.
Create a contextual filter by nid, default value = node id from URL.
Create a relationship with the parent.
Add the siblings field (use parent relationship), on "Multiple field settings", uncheck "Display all values in the same row" .
Add the sorting (use parent relationship), parent delta. for the siblings field.
Comment #11
justaman commentedComment #12
fadgadget commented#8 seems to work in a block also BB but you probably see that now.
Thanks studio-days. works great for me on term pages but im struggling to create a url pattern for the node
Node ---> [node:your-term-field:parent]/[node:title]
ive got entity token enabled. Got lots of tokens but none seem to e working in the url pattern. the closest thing i have to your suggestion is
[node:field-tags:1:parents] (also 2,3)
the node url doesnt change to the pattern. is there something im missing anyone?
tx
Comment #13
fadgadget commentedalso im a bit worried about my term urls that ive created via this way.
Sport (/sport)
-football /sport/football)
--Scottish football (/football/scottish-football)
---Scottish League One (/scottish-football/scottish-league-one)
i think i would need to have something like this for 'scottish league one'
sport/football/scottish-football/scottish-league-one
but then again that might be a wee bit deep. so maybe this would be preferable if poss...
Sport (/sport)
-football /football)
--Scottish football (/scottish-football)
---Scottish League One (/scottish-league-one)
mmm i dunno about the last suggestions. i think im in confusion now which is a shame as ive finally got a sibling menu on my term pages. i refuse to use Panels just for this one block.
Comment #14
mustanggb commented