3

I want to classify my content within the following categories:

  • Technology
  • International Politics
  • Education
  • Religion
  • Sports

They are shared among my content types (e.g. news, page).
I want to create listing pages filtering by category, something like "news/international-politics" (notice the clean URL).

What is the best way to achieve this?

I've kind of done it with a shared taxonomy and a view per content type with an argument, but then I can't use the taxonomy links and have to build them by hand (cleaning the taxonomy name), but it's not a very clean solution.

7
  • For which Drupal version are you interested?
    – apaderno
    Apr 7, 2011 at 10:28
  • drupal 6. I thought it wouldn't matter...
    – sharpbites
    Apr 7, 2011 at 10:32
  • @sharpbites: Views for Drupal 7 is quite different from the version for Drupal 6. If then you are looking for a different module to use, there are modules without a Drupal 7 version, and the answer would change basing on which Drupal version you are interested to.
    – apaderno
    Apr 7, 2011 at 10:35
  • I don't understand what you mean by "cleaning the taxonomy name;" may you explain that part?
    – apaderno
    Apr 7, 2011 at 10:46
  • @kiamlaluno I want to clean all the special chars from the category in the same way transliteration does it. For example it should be "news/international-politics" and not "news/International Politics". (It should also filter other chars, not only applying downcasing and replacing spaces).
    – sharpbites
    Apr 7, 2011 at 11:01

3 Answers 3

1

To create the view

  1. Create a view with appropriate fields/whatever.
  2. Add the first argument Node: Type.
  3. Add the second argument Taxonomy: Term.
  4. For the second argument select Transform spaces to dashes in URL.

To create the listing page

Option 1

Bite the bullet and create the page in code. You just need to iterate over the content types and terms, creating the links as you go.

Option 2

Create a normal view that lists the taxonomy terms. Use link rewriting in the view to output a link that's contains the term name and content type, and is easily identifiable. Eg. custom_term_list/news/International Politics. Use custom_url_rewrite_outbound() to translate this to /news/international-politics. Gotta be careful not to slow the site down here.

Option 3

Use a terms as nodes paradigm. (I think this would work.) Create a content type for which each node will refer to a term. This can be done with taxonomy_node, nat (Node Auto Term), or even content_taxonomy (and maybe others for all I know). Add a computed_field that calculates the name of the term with spaces turned to dashes (or whatever). Then it would be easy to make the listing. If you want the node term to be created automatically when a term's created, then you'll need to use one of the first two modules mentioned.

Those are the only approaches I can think of to create listing pages. I think I'd just go for the first one.

4
  • Not really. That's what I have currently (I use multiple views instead of the node type as first argument, but that makes no difference). The problem is, I want to make a listing of the categories, each linking to its page (news/whatever-the-category-name)
    – sharpbites
    Apr 8, 2011 at 10:17
  • @sharpbites So on one page you want to have links to news/technology, news/international-politics, etc., pages/technology, pages/international-politics, etc.?
    – Andy
    Apr 8, 2011 at 12:28
  • No, each page has links to its own category pages. On news there are links to news/*. On blog there are links to blog/*
    – sharpbites
    Apr 11, 2011 at 14:55
  • 1
    @sharpbites Actually makes no difference, you can still use all three approaches here.
    – Andy
    Apr 12, 2011 at 8:44
0

I found a way to do it using distinct vocabularies per content type togheter with nat and tvi.

1
  • 1
    can you expand on this a bit more so other could accomplish the same thing?
    – Chaulky
    Jun 9, 2011 at 0:47
0

It took me days to work this out but the answer is in this video

Hierarchical Views Catalog using Taxonomy

https://www.youtube.com/watch?v=y1jqu8JnLbU#t=511

In Views Use The Rewrite results Output this field as a link

Make sure your title field in the Taxonomy View doesn't link to the taxonomy term, but it outputs the field as a link to "catalog/[name]" that way your catalog names are clickable :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.