0

I was wondering whether it is possible to have a taxonomy whose URL's are based on taxonomy. Example: I have a taxonomy list called 'Gallery type' which exists of the following items in which 'Pictures' and 'Movies' are higher in the hierarchy than the subitems:

pictures

  • pictures-2009
  • pictures-2010
  • pictures-2011
  • pictures-2012

movies

  • movies-2009
  • movies-2010
  • movies-2011
  • movies-2012

I also have a (gallery) content type in which it is obliged to select an item from the taxonomy list (actually a submitter should select two items: one main item and one subitem (e.g. 'pictures' AND 'pictures-2012'). Then I have made a view for every item in the taxonomy list so that every taxonomy term is a page that contains links to the pages that are created with the term as obliged option (I know that this is hard to follow, but please bear with me)

Example: I create a new gallery named 'Animals' and select the options 'pictures' and 'pictures-2012'. This gallery 'Animals' will be visible on the corresponding views, i.e. /pictures AND /pictures-2012. The page its URI however will be /content/animals. My question is then if it is possible to make the URI follow the hierarchy posed in the taxonomy. In this case it would be: /pictures/pictures-2012/animals

If anything is not clear, please do tell me! English is not my mother tongue, so forgive me if it contains a lot of syntactic and/or grammatical errors!

  • 2
    Not to tell you what to do since I don't know the full use case here, but...... I would think it would be a lot easier and more powerful to have another taxonomy that is the year instead of type-year. For instance, if you did it that way all of this would just fall into place from a hierarchy standpoint plus with the added bonus of being able to sort/search by year, eg, give me everything in 2009, or give me all pictures. just 2 cents ;) – Jimajamma Mar 24 '12 at 19:28
  • @Jimajamma do you mean a whole seperate list? So that I have a list called 'Gallery type' and one called 'year'? Or am I missing your point? If this is what you mean, how can this be hierarchially more logical? – Bram Vanroy Mar 24 '12 at 22:03
  • if you have a one taxonomy vocabulary with a terms of years, eg, 2009, you can use it to tag any type of content with the year 2009, whereby with having a pictures-2009 term, that can only categorize pictures in the year 2009. same with movies. also with those terms you can't easily find all content from 2009 if you if wanted to. so I would think it to be cleaner to create two vocabs. also, from a hierarchy standpoint, you can set up a view to look at something like of content/%type/%year and then select on type and year pretty easily. just separating things more cleanly. – Jimajamma Mar 25 '12 at 0:34
  • Well I've done what you said (i.e. deleted the pictures-2009 etc. and added a new list called 'year', cotaining all the different years). But what do I do now? I added an extra field to the gallery type, so one has to specify whether it is a picture or movie gallery and then one has to specify the year. Okay, that's fine. But how do I put up a view which gives me a hierarchial structure then? How can I put the year 'higher' than the gallery type? – Bram Vanroy Mar 25 '12 at 11:47
  • It seems to be better if I just put it like this: pictures and movies as main taxonomy terms and the years as subterms. This way I can easily create aliases. – Bram Vanroy Mar 25 '12 at 11:58
1

From the comments, this is one way how I would do this:

  1. create a taxonomy vocabulary called gallery type.
  2. create a taxonomy vocabulary called year.
  3. populate them with the appropriate terms.

Then I'd create a view:

  1. filter it on gallery type (or whatever content types are tagged by the above vocabs)
  2. also filter it on all nodes that are published

In arguments (d6) or contextual filters (d7) I'd put in two arguments. They would be taxonomy terms and you can select them from the dropdown list from taxonomy:

  1. For the first, select taxonomy term and then in validation, select taxonomy and term again and restrict it to the gallery type vocabulary.

  2. For the second select taxonomy term and then in validation, select taxonomy and term again restrict it to the year vocabulary.

Then, in the Fields, select whatever fields you want displayed. For ease here, just select node title, but once in production I'd imagine they'd be title, a picture or image or two, a description, etc.

Now, create a page display in the view, and in the path enter

myfirstview/%/%

Change myfirstview to whatever makes sense on your website's hierachy. What the two %'s do is substitute in the taxonomy terms above.

Save everything.

Now you have created a View that does all that hierarchy for you. So, if someone goes to...

www.yourhost.com/myfirstview/movies/2009

...Views will create the page for you and display the title of whatever content has been tagged with both movies and 2009 (views takes the hardcoded myfirstview and substitutes in the movies and 2009 and then matches them against what content is tagged with those terms) and if they went to...

www.yourhost.com/myfirstview/pictures/2012

...Views would create a page of all pictures from 2012 doing the same logic.

What is nice is that you can then create a views that filter on only one of the vocabularies, eg,

www.yourhost.com/mysecondview/pictures

that would list all pictures

or

www.yourshost.com/mythirdview/2012

that would list all content from 2012

As you get more comfortable with Views you can then add all kinds of different sortings, eg, sort by posting or last edit date, sort alphabetically by title, etc, but this should get you on your way. Just play around with the settings and hit Preview a lot. You'd be amazed how simple it is once you get past the up front daunting nature of all the various options you have.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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