Hi,

I am thinking about this already for a year, but until now no solution yet.

What I would like is to be able to set a different template on a different level of taxonomy.
For example:
-Country
---Region
------Place

Taxonomy levels. With region as child of country and place as child of region.
When you fill in this taxonomy what I would like is that I have the possibility to have different panels-pages which I can select for different taxonomy levels.
SO when you are selecting a different level of taxonomy with for example panels_taxonomy, then a different panels-page (template) is fired to the screen.

Somewhat same functionality as the node/% or taxonomy/% functionality but with the possibility to change panels-page related to the specific vocabulary and the child level you are on.

This way panels can help to build a more level template website.
The usage of this will in my perspective boost the possibilities to use Drupal a lot!!

Greetings,
Martijn

Files: 
CommentFileSizeAuthor
#38 ctools_term_lineage.tar_.gz1.87 KBzship

Comments

merlinofchaos’s picture

You can do this, but you would have to write a special version of the taxonomy tid argument. In fact, this would make a fantastic DROP tasks to turn it into a tutorial, because it's a good example of a specialized use-case which is actually possible with a fairly small amount of code.

Summit’s picture

Hi Earl,

Quote:you would have to write a special version of the taxonomy tid argument. What do you mean by this?
Do you may be mean that the hierarchy level (depth) is also taken into consideration.
I will write the tutorial when we get this rocking. Promised!
Thanks for your quick reply!
greetings,
Martijn

merlinofchaos’s picture

Yes, the argument can control what criteria create a new display; so instead of vocabulary being the criteria, it could be depth of term.

Summit’s picture

Hi Earl, Let's see if I understand you correctly. What I would like is the following.
I need a panel-page for
- country [Nepal for example],
---region [Kathmandu-valley for example] and
-----city [Kathmandu for example]

If I use http://www.example.com/regional/nepal I want the country panel-page to fire up (regional is my vocabulary).
If I use http://www.example.com/regional/nepal/kathmandu-valley the region panel-page should fire up
If I use http://www.example.com/regional/nepal/kathmandu-valley/kathmandu the city panel page should fire up

It is not possible to set the depth in the url, because the url will then not be nice anymore regarding SEO, right?
Also the url's are build through pathauto so difficult to change?
How to proceed with this example?

Greetings,
Martijn

merlinofchaos’s picture

Since the URLs are built through pathauto, all the URLs as far as panels is concerned are taxonomy/term/TID regardless of the depth.

Upon loading the taxonomy term, you can load the taxonomy tree and discern the depth of the current term. Once you have this number, you can easily make a determination of which 'display' to use, much the same way that it currently will do for vocabulary.

Summit’s picture

Hi Earl,
How would we proceed in this? How do we get the taxonomy tree and depth of the current term inside the panels-scope?
Does it need to be placed in a .inc file for panels?
greetings,
Martijn

merlinofchaos’s picture

I'm sorry, I've given all the explanation I can here. There's enough information here to do it, but you have to know Drupal and some PHP and be able to write some code. If you can't, then the answer is that you can't do this.

Summit’s picture

Hi Earl,

Thanks a lot for your remarks, and sorry to disturb you on such a minor issue.
No I am not a programmer so I can't do this on my own. But I am eager to learn. And learned the last year a lot about Drupal.
Your remarks load the taxonomy tree and discern the depth of the current term

<?php
$vid = 1; /* <---- put correct vocabulary ID here */
$terms = taxonomy_get_tree($vid);
foreach ( $terms as $term ) {
$current_depth = $term->depth;
}

Is this something in the way you are thinking?
Or will this snippet be more in the way of thinking: http://drupal.org/node/123634#comment-689151
where to put the resulting code then please?
May be somebody else can step in to help this going? Please assist.
I think to get hierarchical support for panels 2, is great for panels 2 and for drupal as a whole to support hierarchical websites!

greetings,
Martijn

sdboyer’s picture

Hi Martijn - as Earl has pointed out, what we'd be looking looking at doing here isn't all that complicated IF you know where to look. I'll take a crack at putting together the code you need for this functionality when I have some time over the next couple days. The changes should be in with the BETA3 release of Panels2.

Summit’s picture

Great! Looking forward to it, thanks in advance! greetings, Martijn

sdboyer’s picture

Sorry, this has gotten pushed down on my priority list, and unfortunately probably won't make it in for beta3. I'll post here with more details as I have them.

Summit’s picture

beta4 is out! great

Summit’s picture

Title: Panels-page depending on taxonomy level like taxonomy/% » Hierarchy in taxonomy (tree) through panels 2 (using taxonomy depth)

changing title

Summit’s picture

Hi, Can anyone please get into this functional requirements for panels 2. Getting hierarchical panels!

What I would like is that related to the depth of taxonomy another panel-page-template will show.
Almost the same as the %term panels override, but say you have 3 levels in the taxonomy.
You get a %term/1depth panel-page, a %term/2depth panel page, %term/3depth panel page and %term/4depth panel page
This way going a level deeper in taxonomy gives the possibility to set up sites with hierarchical aspects like:
Country panel page template
--Province panel page template
-----Village panel page template
--------Accomodation panel page template

So the panel page for a country like Nepal will be possible having a complete different lay out than the panel page for Kathmandu.
Thanks in advance for considering this functionality to get panels the hierarchical solution for drupal websites!!

EDIT: Sam, Earl, congratulations on Beta4!

greetings,
Martijn

Summit’s picture

Category: support » feature

Hi Earl, Sam,

I try to get this doing from your notes so far:
Your remark: Upon loading the taxonomy term, you can load the taxonomy tree
Loading tree:

$depth = 0;
$terms = taxonomy_get_tree($vid, 0, -1. 1);

Your remark: Then discern the depth of the current term
Discern depth:

foreach ( $terms as $term ) {  
  $depth = $term->depth;    
}

Question to community: is this the correct code to get the depth of the current term?

The next of the remarks are:
Once you have this number (the depth), you can easily make a determination of which display to use, as is now with panels-2 vocabulary usage.
Question to community: Can anyone help out to get this into code?
Is it related to this code from panels2/arguments/term.inc

switch ($conf['input_form']) {
    case 'tid':
    default:
      if (!is_numeric($arg)) {
        return FALSE;
      }
      $term = taxonomy_get_term($arg);
      break;
    case 'term':
      $terms = taxonomy_get_term_by_name($arg);
      if (count($terms) != 1) {
        foreach ($terms as $potential) {
          foreach ($conf['vids'] as $vid => $active) {
            if ($active == 1 && $potential->vid == $vid) {
              $term = $potential;
              break 3; // break out of the foreaches AND the case
            }
          }
        }
      }
      $term = array_shift($terms);
      break;
  }

Thanks a lot for your reply!
greetings,
Martijn

Summit’s picture

Category: feature » support

My first tryout is related to arguments/term.inc, please respond?

switch ($conf['input_form']) {
    case 'depth':
      $terms = taxonomy_get_term_by_name($arg) as $result) {
      if (count($terms) != 1) {
        foreach (taxonomy_get_tree($result->vid, $result->tid) as $term) {
       $depth = _taxonomy_depth($term->depth);

              break 3; // break out of the foreaches AND the case
            }
          }
        }
      }
      $term = array_shift($terms);
      break;
  }

Thanks a lot for your reply!
greetings,
Martijn

Summit’s picture

Category: feature » support

Was double post.

Summit’s picture

Category: feature » support

Hi Guys,
I can't get it fixed..it is too complicated for me without more documentation. I asked a programmer and he also suggested to go back to you guys.
So..I wait on you Earl/Sam or anybody else also wanting a hierarchical panels 2 template solution
Thanks for all your hard work already!

greetings,
Martijn

Summit’s picture

Category: support » feature

Changed to feature request. Greetings, Martijn

Summit’s picture

Category: support » feature

Hi Sdboyer,

Any progress in this field please.
I would very much like panels for hierarchical website, but can't get it working.
Thanks a lot in advance for your reply.
Panels seems so great to get this working!

greetings,
Martijn

humanoid’s picture

Hi all,

I feel happy about this thread. That is exactly what I want to have too! Is there any chance to complete this feature to have hierarchical panels. Would be great.

greetings
Jürgen

sdboyer’s picture

Status: Active » Postponed

Hi Martijn et. all -

So, I'm very sorry to say that I'm going to have to postpone this issue.

Once I (FINALLY) set about thinking what the best way was going to be to perform the differentiation-on-taxonomy-hierarchy-level you're looking for here, I realized that we've got a problem. I _could_ write a specialized context that would be able to take care of this, but it would be a bastardized version of context that really steps over into the territory of the only panels plugin that is more abstract and obscure than context: switchers. Earl implemented switchers a couple months back; basically, they're a mechanism that basically abstracts the things you're looking for out of context per se, and allows them to be defined arbitrarily.

This general concept behind switchers has been implemented a few ways, but we are _far_ from settling on a systematized way of actually implementing it. Perhaps most problematic is that at this point, the switcher is nothing more than a very bare API, and I'd have to write the whole interface between the that API (which is still in its pretty young phases) and the existing UIs. That's a hefty job that will require a number of hours, but I can't even really start on it until we do a fair bit more thinking about how we want Panels to evolve post-D6 and on into Panels3.

So yes - while I COULD write a context that did this, I would never commit it to Panels, because it's simply not the right way to approach the problem. Panels is complex enough as it is, we don't need bastardized code getting in the way. So I'm sorry, but it's going to be a little while before we can get to this, because when I'm not working on Panels, I've got another project, and a job, that's absorbing pretty much every waking moment of my time.

I'll post updates here as they come.

Summit’s picture

Hi Sam, Earl,

I understand this. But thinking further...wouldn't it be absolutely great to have the depth of taxonomy likewise the vocabulary be used? Would that also be hard?
It would be a smashing hit for panels 2 to be able to AND have different panels-pane related to the vocabulary we are referring to (already implemented feature) AND have panels 2 to have different panels related to the depth of this same vocabulary terms!!!

Wouldn't this make the panels system THE flexible system to use for GUI purposes? Also Country-Region-City websites can be build then.
May be something to bring on as a summer of code or other sponsored program. I really would like to be able to build panels based on depth of taxonomy terms. No other hierarchy system needing anymore than.

I am very, very sorry I can't program it myself, but would cosponsor a thing like this very much.
Please reconsider getting the hierarchy in, and of course the panels-way. May be possible first only have an option than only one possibility of depth on all vocabulary..and not as is possible with vocabularies, having pane-chooses for all?

Couldn't there be a modulair approach, first starting simple? and not postponing the featue as a whole?
Thanks a lot for reconsidering! And thanks a lot for maintaining a awesome module!

Greetings,
Martijn

sdboyer’s picture

Martijn - it's not a question of whether or not this particular feature would be great, or what Panels could/should/might be able to do. It's not even a question of money for sponsorship. And while I'm always looking to hear from people about why their use cases are compelling and potentially useful to the entire Panels user base, that doesn't mean that it's the only factor I consider while deciding whether or not something goes in. When approximately the same effect can be achieved by other approaches, albeit less elegant ones, then I'm that much less inclined to bend over backwards.

I thought about my answer in #22 very carefully before I wrote it, because I know how long you've been asking/waiting for this, but it seems I wasn't clear enough. So let me be blunt: In my estimation, Panels is not ready to support this feature properly. It's not about trying to find time, or bringing someone on who has some time, or looking to sponsorship programs to find a coder. It's about only one thing: more theoretical groundwork needs to be done before we can really do this - or at least, can do it in a way that I'd be willing to see it committed.

Maybe I'm wrong, and if someone comes along with a patch that proves that's the case, then I'll happily admit it and set right to work adjusting my theories and getting the patch in. But I'm a bit miffed by your request that I reconsider, because I can think about it all day and it won't change the reality: the code simply isn't ready for this.

So again: I'll keep my eye on the issue to see if anyone wrangles up some patches and proves me wrong, but until Panels has evolved enough to be able to handle this kind of operation (I'd estimate a few months, at least), I will not work on this.

Summit’s picture

Hi Sam, Thanks again for your explaination and thanks for keeping an eye on this issue! I am sorry that I carried away in enthousiasm and understand now completely what you are saying.

Greetings,
Martijn

pkej’s picture

have you tried to use templates? You might also look into something like the NAT module for creating nodes of a certain contet type when a term is created? A content type a panel pages might be created. Just browse the modules list for other methods of circumventing your problem.

Best regards

Summit’s picture

Hi Paul,

Could you tell me how I get hierarchy in through template please?
Thanks in advance.

greetings,
Martijn

najibx’s picture

We could put conditional so it chooses different panel depending on the level of term(if current term has child). We first define a vocab, this code might help? taxonomy_get_children(). It is possible to know if the current term still have a child. If yes, then use a IF condition to select which panel to use.
someone help putting this in code, if this is ever possible?

Might only be useful if has 2 level ?

Country (vocab) - use default if term not defined
State (has a child)
Hotel or specific item info (no more child now chose other panel.)

-najibx -
Drupal in Malaysia

Summit’s picture

Hi Sdboyer,

Isn;t a solution like: http://drupal.org/node/258383#comment-942138 possible to get taxonomy depth inside the context?
So hierarchy can be got from that?

Greetings,
Martijn

sdboyer’s picture

#258383: Pass Context configuration with context to add/edit of blocks. is more or less unrelated to this issue. It's similar conceptually, in that you're sort of 'beefing up' an existing context with additional, more specific information. However, the challenge in executing this properly is considerably greater for taxonomy than with node types; whereas node types are guaranteed (for our purposes) to sibling children in a one-level hierarchy of sorts, the relationships between taxonomy terms are vastly more complex.

Summit’s picture

Hi Sdboyer,
thanks again for your thorough answer. sorry if I am to impatient for this feature.
waiting for the right ingredients, right? I thought because of this answer of Earl one day, about this combination of posts: http://drupal.org/node/231911#comment-763215.
Sorry if it is a mistake to think this way.

greetings,
Martijn

tille’s picture

hi there,

I was looking for something like this - and found this panel-groups-thread very useful:

"Different Panel for each Level of a hirarchical Taxonomy"
http://groups.drupal.org/node/13046

greetz, till.

Summit’s picture

Hi,

Could a plugin to the hierarchical select module www.drupal.org/project/hierarchical_select (which I use because of its great gui and many advantages above normal taxonomy), be an answer to hierarchy connection to panels 2?

greetings,
Martijn

1kenthomas’s picture

+0; subscribing.

sun.core’s picture

Version: 5.x-2.x-dev » 6.x-3.x-dev
Summit’s picture

Status: Postponed » Active

Hi Sam, Earl,

Set this to active again for Drupal 6. Still not getting a nice hierarchical menu system with templates on taxonomy depth level using panels/ctools. I tried every possible solution, this one is the closest to a short-term solution I think right now: http://drupal.org/node/795998: Using one panel-page-template, but changing the content of the template related to the term depth.

I am not successful in using this solution yet, and can't find anywhere help to get this working.

Am I correct for now this solution (http://drupal.org/node/795998) is the best solution for now to get different content regarding different term depth?

greetings,
Martijn

1kenthomas’s picture

Bump; //requesting status, should we keep in queue?

zship’s picture

FileSize
1.87 KB

I recently ran into this issue myself. Wrote a quick-n-dirty ctools plugin for term depth. I have no prior experience writing ctools plugins, but we all know merlin writes easy-enough code to extend, deserves all the women, etc., so there shouldn't be too many places I went wrong. This module requires the Taxonomy Lineage module and (of course) ctools.

Here's the set-up: Enable the module (Chaos Tools Term Depth). Make a panel page with a Term ID argument. Create a relationship "Term Depth" with that argument on the "Contexts" tab. Go to "Selection Rules", pick "Term Depth", and enter a term depth or range of term depths to which the variant should apply. Enjoy.

Summit’s picture

This seems great! I will test this soon. Greetings, Martijn

Summit’s picture

Hi zship,
Couldn't http://drupal.org/project/views_tree be used also somehow with this term_lineage submodule.
For Drupal 7 it is suggested to use this in favour of term_lineage, see http://drupal.org/node/1012064#comment-5411548 discussion.
Greetings, Martijn

Summit’s picture

Hi Zship, Finally time to test your method in #38 it worked for D6! Would you be able to also make a solution for D7 please?
See feature request: http://drupal.org/node/1446626
Thanks a lot in advance for your reply!
greetings, Martijn

zship’s picture

Hi, Martijn. Well, unfortunately I haven't done any D7 sites and I'm not really doing Drupal work any more. It's hard to believe that you first posted this almost three years ago and there's still not a great solution. I think if you want a D7 solution, you're probably going to have to think about writing it. I made my D6 solution by looking at other ctools plugins to get a feel for their flow. Ctools itself includes a plugin example. The lineage module doesn't have a D7 version either, though. There's some development work, for sure.

Perhaps you might consider laying out your data differently? In my case, the site was an ebook ecommerce site and the client specifically wanted levels of the taxonomy to mean different things (first level was called a "Subject", second level a "Format") and therefore display differently. I personally thought that was a very awkward choice, and if it were up to me I would have gone with a Newegg style for displaying products. That is, allow the user to filter just one view by taxonomy term regardless of level. Just a thought.

Summit’s picture

Hi Zship,

Why did you stop doing drupal work? It's such a great system!

I have an hierarchical website with countries, regions and places, and therefore in itself it is hierarchical.
I use one vocabulary which has those term-depths.
Your solution works great on D6! On D7 a great panels developer is volunteering to try to build a solution!
See: http://drupal.org/node/1446626#comment-5628780

I am not a programmer, and panels/ctools code looks for me very complicated sorry..and yes almost three years ago..times flies!

Greetings, Martijn

japerry’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)