Hey folks,

I think I understand taxonomy basics and have gone through the handbook pages about taxonomy. My issue comes around dealing with taxonomies across different content types. The "problem" (not sure it is one) is that if I were to click a taxonomy it would show all nodes in that taxonomy accross different content types. I'm not sure that would be logical to my users.

Consider my scenario:

I run a marching band website. The "meat" of the site is stories that are posted about upcoming or completed events and competitions. So far I'm using a simple vocabulary for categorizing stories (multiselect)

- Marching Band
- Jazz Ensemble
- Winter Percussion
- Winter Guard
- Band Parents Association
- Concert Band

We also collect and post three media types to our site...

- Video
- Photosets
- Audio

I have already created custom content types using CCK for displaying my videos as nodes, and photosets as nodes. Here is the where the problem comes in. Certainly it makes sense to tag each video or photoset node with the same taxonomy as I do stories. But from the perspective of my users, I'm not sure it will be intuitive for example if they are looking at a list of photosets and they click on "Jazz Ensemble" for it to come up with a page that mixes all the "Jazz Ensemble" stuff (stories, video, photosets, audiot, etc.) together on one page. I think it would probably make more sense to my users if instead it came up with a list only of "Jazz Ensemble" photosets since that is what they were looking at in the first place.

Now before you should "Views!" - I certainly know that Views could handle that. I do plan to use Views for a number of things, but in this case it feels like Views should be needed for something like this. Also to get the behavior I think my users would expect I would not only have to use Views, but I would have to use PHPTemplate (or something) to change the normal way that Drupal displays taxonomy links below nodes in a node list.

One alternative I considered was making a "shadow" vocabulary. Here is what I mean. Basically I would create a new vocabulary with the same terms as the regular taxonmy such as...

- Marching Band Media
- Jazz Ensemble Media
- etc.

and assign that to the media content types. That would prevent it mixing stories with media when someone clicks a taxonomy term, but it would still mix media types together, and frankly it just doesn't feel like a very good idea.

Anyway, has anyone had similar issues? Were you able to handle them well without Views and templating? Or do I just need to bite the bullet and go that direction?

Thanks for reading my long post! Hopefully this conversation will help others with similar issues.

- Peter

Comments

nancydru’s picture

Filtering by current content type shouldn't be hard in a module, if you have the knowledge to write one.

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

winston’s picture

Not sure a module would even be needed if all I wanted to do was solve my specific problem in a particular way. A combination of Views and theming would probably do it.

For this thread, I'm really hoping for a robust discussion about the interaction between taxonomy and content types. In some ways I'm more interested in a discussion about site design/structure than about solving a particular problem.

More along the lines of "here is a specific problem I'm having that raises a lot of general questions about proper use of taxonomy, content types, etc."

Thanks,

Peter

zahor’s picture

Wouldn't creating Organic Groups for each of those help? With each one having its own Organic Group gallery, which is then categorized.

winston’s picture

OG seems more like something to allow users to create their own taxonomy in an "organic" way. My site on the other hand is fairly straightforward. Not too many contributers, and the "topic" of the site is fairly specific (Band programs at our local high school).

Can you explain what you had in mind?

- Peter

FabriceV’s picture

No solution to you. I have just looked at "content" and "display" and "taxonomy" modules... But a related question.

How to efficiently mix content type and taxonomy to build navigation and page display using these both criteria, without having to write a taxonomy term equivalent to each node type and have to tag accordingly and manually each new node?

thanks.

jonjo’s picture

As with the original post, a 'best practice' approach to this kind of site structure would again be really useful for novice users.

As a new user my biggest question is rarely "Can I do this" but rather "Am I doing this the best way". A 'best practice' approach for adding modules to Drupal is I think in-line with the 'drupal approach' to coding it but it's often difficult to determine best practice and (with limited PHP knowledge) it often feels like I'm 'hacking away' on top of a nice neat code base by using way to many modules in order to acheive simple design patterns.

Don't get me wrong though...I do love drupal's flexibility of course! It's just a question of harnessing it.

winston’s picture

Exactly the kind of conceptual questions I'm struggling with.

There was a lullabot podcast recently about "deprecated" modules and drupal features and one of the lullabots proposed (if I recall) that perhaps taxonomy itself is deprecated in a land of CCK, views, etc.

There was a fairly robust discussion about this and I don't think there was general agreement. But it did raise a lot of questions in my mind about how far one should expect taxonomy to go and what it needs to be combined with to really solve problems.

Let me advanced a new version of my scenario with a suggested "solution". Keep in mind I haven't used some of the things here so please forgive if I get some things wrong...

Consider:
Stories on a site that can be categorized with taxonomy terms as one or more of the following types...
- Marching Band
- Concert Band
- Jazz Ensemble
- Band Parents Association
- Winter Percussion
- Winter Guard

Now consider 3 different media content types on this site...
- Audio
- Video
- Photosets

Now consider that the 3 different media content types should share the same taxonomy terms as the stories

Now consider that a user navigating the site might expect the following...

1. If they are looking at a story list (home page say) and they click on a taxonomy term they would expect to see only other stories of that taxonomy (not have audio, video and photoset nodes mixed in).
2. Likewise if they are looking at a specific media type (say photosets), and click on a taxonomy term they would expect by default to see other photosets of that taxonomy (not stories, or other media types)
3. Nice to have. A "Find Media" option. Can be included as a menu item, and perhaps at the top of a media page listing. Find Media would allow the user to select one or more media content types as well as one or more taxonomy terms to find a result list (Find all Video and Audio for Winter Percussion).
4. Nice to have. A related media field for each story node.
5. Nice to have. A related stories field for each media node.

So my questions/comments:

1. Does that make sense as a layout/organization for the site?
2. Does it make sense to share the same vocabulary for all these content types?
3. If I share the same vocabulary for all these content types is it a given that I will have to do a bit of work with some combination of the follow to get the kind of behavior I'm describing above?
- CCK
- Views
- PHP Templating (or perhaps a custom module) to handle displaying "custom" taxonomy links below items in a node list.

Thanks,

- Peter

jonjo’s picture

1) Layout make sense? - Yes this makes total sense from an Information Architecture pov (including the 'nice to have' "Find Related Media" links)

2) Sharing vocab make sense? - Totally. I think a basic knowledge of relational databases suggests any other solution is likely to mean redundancy which means mess further down the line.

3) Solutions? I too am looking forward to someone with greater Drupal-wisdom giving some suggestions for this...I'll have a think, but it might be a case of the blind leading the partially sighted. I only spoke up to show support for what I think is a great topic of discussion. Good luck!

joachim’s picture

I'm going to second that comment:
1. Yes
2. Yes
3. It seems to be that way, unfortunately.

I've had a similar problem designing a site. I want topics to apply to news stories, images, and a few other content types, but I don't think that a feed of mixed content types is what users want, nor does it always make sense.

The pie in the sky idea that springs to mind would be for a ticky box in each vocabulary's admin settings called 'Segregated'. Select that, and when you click 'Marching band' on a photoset, you only get photosets; click the same term on a Video node and you only get video.
No idea how that could actually be implemented...

nancydru’s picture

Dries is proposing a new hierarchical representation that might very well do exactly what you're looking at.

However, I have to disagree on one point. If I was visiting your site and was interested in the jazz ensembles, I would want to first visit a page giving me the chance to see all content type, not just the last kind I was looking at. I would then decide if I wanted to narrow it down. So, for me, mixing content types would be exactly what I was looking for.

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

winston’s picture

You may very well be right. I don't pretend to be a UI guru.

I think what I'd like to do is get my site close to the way it makes sense to me, then repost to get opinions on the usefulness/friendliness of my approach. I'd certainly appreciate your opinion at that time.

Right now I'm working on solving a much more mundane problem (namely I don't want to display the node title when the photoset taxonomy is displayed, as I'm using the contemplate module to display the title in the body with a direct link to the photoset on flickr, and having another title that goes to a "full" node representation which is identical to what the user sees in the taxonomy listing is not helpful). Saw a phptemplate snippet, but it didn't seem like a great solution.

- Peter

winston’s picture

For those who are tracking...

So I solved a couple of mundane problems and hoping to get this conversation going again. Here is a link to my site...

Stamford High Band

If you look on the home page you see it is a fairly "newsy" site. For example the first article is categorized as "Marching Band". If you go farther down you'll see news categorized in other ways such as Winter Percussion, Band Parents Association, etc.

Now if you go to the media/photosets menu at the left or media/video you can see that we have photosets and video that cover these same topics, but at the moment I havn't added that vocabulary to these content types. But imagine I had for the moment.

So you are a user, you want to look at pictures so you go to media/pictures. You want to narrow it down so you click a link to say winter percussion to see photosets only tagged with winter percussion. Ooops, you get a mishmash of photosets, video, news, and anything else I may categorize with that vocab in the future! To me, that doesn't seem intuitive or what the user would expect.

So am I wrong? Is a mishmash of various content types what users would expect?

I'd like more control over this. So for example, if a user is looking at photosets, theme the listing to display links for "marching band photosets" and "marching band media" and "marching band news" where the first would go to only photosets tagged marching band and the other would go to any "media type" (I have two at the moment) tagged marching band, and the last would go to only news story media type tagged marching band.

Has anyone created sites with that kind of control? What was the best practice to do it?

- Peter

gemini’s picture

Peter, I have exactly the same problem and have been trying different approaches to solve it.
BTW, here is my attempt to ask the same question http://drupal.org/node/207877

Regular taxonomy URLs without nice aliases allow you to do whatever you want.
For example: taxonomy/term/1,2 can be mypath/voc-one-term-one/voc-two-term-two, but in reality we can not achieve the second URL that easily.

Here is what I'm thinking.

1. First of all we would have to make all taxonomy terms aliases for all shared vocabularies in the root without hierarchical sub-folders
like this in the path-auto: [cat]
this way each term alias would be a word or a phrase and it will have a unique index if term repeats itself in sub-terms or other vocabularies. So we can be assured that everything in a view's URL between slashes is a single argument and it's unique just like term id.

2. Then adjust theme_links to replace all [href="] to [href="current-vuew-url"] in the $output.
This will make all the terms urls related to the current view url.

3. Edit views' argument handling code to read arguments and make sql request for each of them in the {url_alias} table to extract terms' ids utilizing this code http://drupal.org/node/125629#comment-523242

4. I have no clue what will breadcrumbs say, but depending on the modules we use, we might adjust those too.

This just came to me when I started writing things down on the paper. I already tried all these steps, but separately and they worked. I just need to rewrite them again with the correct unique aliases and that's it. My problem was, that I started using hierarchical aliases like /united-states/new-york/new-york - this is one alias for the city of New York and in the view I will have problem figuring out if it's one argument or three of them. Even if it's 3 of them - argument 'new-york' is repeated twice and it will find the same term id for each of them even though they have different tids. That's why in the item #1 I siggested to go have all aliases in the root, this way I will loose the hierarchy in the URLs, but each alias with be unique - in this example they would be new-york and new-york-0

Hope this helps.

gemini’s picture

As I described above - I'm using URL aliases since there can not be mistake finding them in the database comparing to the method where you use term names with dashes etc. All aliases are based on [cat-raw] pattern in pathauto.

VIEWS: In the views I have only one argument field Term ID - display all values.

Argument Handling Code:

if($args){
$new_arg = '';
  foreach($args as $arg){
    $result = db_query("SELECT src FROM {url_alias} WHERE dst LIKE '%s'", $arg);

    if (isset($result)) {
      $tid= array();
      while ($nodepath = db_fetch_array($result)) {
        $tid = substr(strrchr($nodepath['src'], "/"), 1);
      }
    }
    $new_arg .= $new_arg == '' ? $tid : ','.$tid;
  }
return array($new_arg);
}

if you print $view array you will see that [args][0] will look like "123,456' and real_url = "view-url/123,456" - where comma works as AND (that's what I need, but if you want to use OR, just change the ',' to '+' in the $new_arg line.

Then in template.php I insterted 2 functions:

//I found this function here in the forums
function detect_views() {
  $allviews = array_flip(views_get_all_urls());
  if ($current = $allviews[arg(0)]) {
      return arg(0);
  } else {
      return FALSE;
  }
}

function view_term_url($url){
  //$term_url = detect_views(). str_replace('/subfolderwheredrupalis', '', url($url)); //if you have drupal installed in a subfolder
  //otherwise
  $term_url = detect_views(). url($url);
  return $term_url;
}

Then we adjust only one line in the theme_links function. Also copy it into your template.php with phptemplate_links name.
See where it says --BEGIN MY CODE-- that's all I added. Basically substituted "/term-alias" with "/view-name/term-alias"

function phptemplate_links($links, $attributes = array('class' => 'links')) {
  $output = '';

  if (count($links) > 0) {
    $output = '<ul'. drupal_attributes($attributes) .'>';

    $num_links = count($links);
    $i = 1;

    foreach ($links as $key => $link) {
      $class = '';

      // Automatically add a class to each link and also to each LI
      if (isset($link['attributes']) && isset($link['attributes']['class'])) {
        $link['attributes']['class'] .= ' ' . $key;
        $class = $key;
      }
      else {
        $link['attributes']['class'] = $key;
        $class = $key;
      }

      // Add first and last classes to the list of links to help out themers.
      $extra_class = '';
      if ($i == 1) {
        $extra_class .= 'first ';
      }
      if ($i == $num_links) {
        $extra_class .= 'last ';
      }
      $output .= '<li class="'. $extra_class . $class .'">';

      // Is the title HTML?
      $html = isset($link['html']) && $link['html'];

      // Initialize fragment and query variables.
      $link['query'] = isset($link['query']) ? $link['query'] : NULL;
      $link['fragment'] = isset($link['fragment']) ? $link['fragment'] : NULL;

      if (isset($link['href'])) {
        //----BEGIN MY CODE-----------------------------
		$link['href'] = view_term_url($link['href']);
	//----END MY CODE-----------------------------
		$output .= l($link['title'], $link['href'], $link['attributes'], $link['query'], $link['fragment'], FALSE, $html);
      }
      else if ($link['title']) {
        //Some links are actually not links, but we wrap these in <span> for adding title and class attributes
        if (!$html) {
          $link['title'] = check_plain($link['title']);
        }
        $output .= '<span'. drupal_attributes($link['attributes']) .'>'. $link['title'] .'</span>';
      }

      $i++;
      $output .= "</li>\n";
    }

    $output .= '</ul>';
  }
  return $output;
}

That's it. Works for me. Every view output terms even from shared vocabularies with paths relevant to the current view.
Good luck!

gemini’s picture

just copy the theme_links function from here http://api.drupal.org/api/function/theme_links/5, name it as mine and find this line
if (isset($link['href'])) {
insert what I inserted. All other functions look fine in the post.

nancydru’s picture

Code should be enclosed within <code> tags. You will get proper display and indentation that way.

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

gemini’s picture

I did that, but it still broke. And when I went back to edit it - the tags weren't available any more... that's when I switched them to regular PHP tags.

nancydru’s picture

I find it behaves a little different if the code start and end tags are on separate lines with the code between.

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

jonjo’s picture

I'm afraid I have no answer for you either but I think I have a very similar "problem". A 'best practice' solution to this situation would be very useful I think (Views or otherwise), particularly for new users like me.

My situation is as follows: I have the same taxonomy vocabulary terms applied to my blog as I have applied to a site section called notes. Notes is a private site section but the blog is public. Now, when I add the tagadelic module, I can correctly configure it to show tags from the relevant vocabulary, but even unauthorised users have access to ALL the tags, not just the ones relevant to the public blog. This is possibly even more confusing than mixed content since my users would frequently see 'No Unauthorized Access' messages should they proceed to follow a 'Notes' only tag. Thinking about it, I don't get the same problem when using the Archives module (which I guess must check content access first somehow)

(Hope that description made sense)

My solution... I arsed around with an SQL query in the tagadelic module for a while then gave up and switched off Tagadelic. Like I say, I'm new :)

lebisol’s picture

Hello everyone,
First of let me say what I relief it is to find this post being how this is my second comment.
Very same line of thoughts of Peter ...
I can confirm confusion as a brand new user as well. I found my self in the same spot when trying to implement 3 levels deep of 'strict structure' of content but it really applied at any level of possbile duplicates. There seems to be a need for "dynamic/related drop-downs" populating with cat->subcat->subsubcat.

As newbie I walked away feeling that my choices are:
-categories = get ready to learn Views and CCK and some PHP" (not a bad thing just too much to accept as a newbie)
or
-content types = organize your content through content types (treating 'book' as a 'parent') with use of only one category called "keywords" or "meta_tags" with free tagging and loose some of the views that came with the core install.

Sort of feeling overloaded with Drupal capablites but Not complaining at all, just wish I have seen this post and saved the a few hairs in the process.
Thanks for posting and listening!
All the best!

nancydru’s picture

There are modules that will give you selectable lists to filter your terms or provide easier selection at node creation. You don't necessarily need to learn Views, CCK, or PHP (as a matter of fact, I discourage that for newbies).

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

lebisol’s picture

Sure but using 30+ mods/plugins/components was my pitfall when used in other cms....it turned out to be a project of keeping up with all the mods vs. actually adding content. I hate learning custom code that has no logevity and can easily become absolete with new version of core. I like views....or the potential I see in them them.

Point was, as someone who used Drupal for few only days I keep thinking that I did somethig wrong and was afraid to speak up and get ignored or slapped with "RTFM" answers...again I don't know this community and forums here are not exacly the 'cutest kid on the block'. Getting to information or confirming it was a pain which is why I was stoked to find this post.

Categories is not one of those parts that "I can work on this later" since it is the bones that hold the meat (content) and dictate how things are presented down the line.

Just a few points from newbie perspetive.
So thanks for keeping this discussion alive!
All the best!

nancydru’s picture

I don't see that many "RTFM" answers in the forums. You may get that on some modules (and you mentioned a few that you are more likely to get it).

Most of us who answer in the forums want to help. But we need concrete questions to answer. "I just don't understand..." is likely not to get answered. However, "I'm trying to get my node to show xxx instead of yyy" is more likely to get a helpful answer.

Also, many of us have found that trying to answer questions here moved us up the learning curve faster.

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

lebisol’s picture

Hi Nancyw,
Thanks for your post of reassurance as well as your tidbits on your site! Very nice!
Now I thought I share my own trial-error experience as a compleate newbie which may help others just starting with Drupal.
When it came to content and organization of it there are two areas I looked at immediatly. Books and Categories. Initally I ruled out categories/taxonomy thinking of them as "metatags" or "keywords" so I focused on books.
Intuitivly I was after structure of:

Main Category - Category - SubCategory

and how Content Types are laied out I thought that we can use content types in a manner of:
Book - Book Page - Story
Main Category - Category - SubCategory
Real world usage:
Autos
-Trucks
--New

Well I realized that his works but I loose the ability of having each Strict Structure of tag=category and if I wanted "tagging" I would have to resort to 1 taxonomy vocabually with free terms and high hopes that autors/contributor would match them...hmm, it would work if I was the only author.
Next issue I faced was that I don't want my content (main category) to be called "book" but rather somethign else...as in this example "autos"...so I followed the "how to rename a 'book' " only to discover you loose printer-frienly feature and potenatially have issues upgrading down the line. Oh great, another dissappointement.

So, next I looked at the topics and ideas of "use taxonomy to organize..."
On my way I was making a vocabulary with a few terms. This confused me even more then trying to add a content since I have my (or so I thgouth) categorization layed throught book-book page-story and underneath my newly added taxonomy/category fields to match the same. As you can imagine...what a nighmare created by myself. :)

Solution:
Finally,I figured that really when it came to written contet type all I need is pages.
I used taxonomy as follows:
1. Created three vocabularies (or as many as you need) all with the type of "page"
- Main Category
- Category
- SubCategory

2. Started to add terms for each vocabulary:
For "Main Category" added:
Autos
Homes
Trips

For "Category" added:
Sedans
Trucks
Utility
1Bdr
2Bdr
TownHouse
England
USA
Bosnia

Categories above are distinct so there was no issue here but the problem was when terms were "the same" or "shared" and could not distinguish what parent the belong to. This problem was especially noted when creating grandchildren with the same name...and it can happen at any level.
My poor-man solution was to take care of the realtionship in the very last SubCategory.

For "SubCategory" added:
Sedans (essentially re-entered Category)
-New (child of and related to Sedans)
-Used (Chilf of and related to Sedans)

1Bdr (essentially re-entered Category)
-New (child of and related to 1BDr)
-Remodeled (child of and related to 1BDr)

This gave me the dropdown of "SubCategory" that now distincts and differentiates between "New" Autos-Sedans and "New" Houses-1Bdr also allowing for unique Aliases.

Pros: No use of Views or any programming. Visual indicator in dropdown of which parent those child records with The Same/Share Name now belong to.

Cons: A lot of "re-entry" for if you have a lot shared therms. No way of prohibiting users of making selection of
"Main Category"
"Category"
"Category"

At the end we can also add a 4th vocabulary of "Keywords" to allow for some free-tagging for each category to allow users for some keywords of their choice while still imposing the desired/strict Categorizing of Content.

Please keep in mind that I am very new to Drupal and I did not "invent the wheel" but rather struggle how to mount this wheel.I would apprechiate any advice and ideas or potential pitfalls for further development?

Again this was more of a "blog" entry here to show how structure of Drupal can be used or misused by a beginner like me.
Ultimately, I will use Views as I get more experience under my bealt simply beacuse I like "eye candy and design" and word "custom" is what attracted me to Drupal.I hope I did not offend anyone in this thread by posting this and hijacking the post, if soo the admins here can freely delete this entry without any hard feelings on my end.
Thanks for your time!

nancydru’s picture

It is certainly an interesting exercise. Never underestimate the value of preplanning such uses.

I suspect that a single vocabulary might do you just as well. It would be a single hierarchy and would have less duplication.

If you'd like some help, use my contact page. You might be able to help me too - I am the maintainer of a module that just might be a good fit for you.

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

nancydru’s picture

My reply to your email bounced.

Nancy W.