does anyone know of a clean way to print different views for different taxonomy terms or vocabularies?
in my case, i'd like to print the default core taxonomy term view for most terms, but print a custom view for all terms in a few of my vocabularies (all i really need to do with that custom view is sort on a CCK/Date field rather than the nodes' post dates). i want to be sure the attached feed also reflects the custom view/sorting. and i'd like this to all be transparent to the user (other than the different sorting, which should be intuitive).
i'm coming up with a pretty hackish solution, and i'm sure i'll kick myself when someone presents something simpler. what i'm doing currently is:
- a simple function determines if the vocabulary meets my criteria for special display based on tid from the path
- page-taxonomy-term.tpl.php prints a call to views_embed_view or plain old $content per my function above
- the special vocabularies are not assigned any path patterns in pathauto (to avoid using core's default taxonomy term view, i don't want these terms aliased)
- for a given node the term links point to the path provided by the custom view's page for terms in the special vocabularies, and normal paths otherwise (which involves logic wrapped around each l(), hard-coding the special vocab links to some degree, etc...)
thanks for any thoughts.
Comments
thinking through this a bit
thinking through this a bit further, i've simplified the approach a bit though it's still a little hacky...
essentially, i'm just avoiding creating path aliases for the "special" vocabularies (i.e. remove the pathauto patterns), and then creating a view (based on the core taxonomy_term view) that provides the expected paths with an argument for the term name (e.g. /specialvocab1/%, /specialvocab1/%/feed, etc). then i've got a little logic in template.php that prints special links from nodes to those terms.
that's where it feels like a little bit of a hack... the relevant function loops through all vocabs to print the terms for that node (something like this). if the vocab meets my "special" criteria, it cobbles together the expected path for the term link (to match the paths of the custom view's "page" displays), otherwise it prints the normal term link.
the caveats here are being sure the link is always cobbled together correctly from the vocab/term names, and the need to add additional displays to the custom view for every new "special" vocab.
i'd still love to hear ideas for a simpler approach! in any event, hopefully my thinking out loud here helps someone else.
that may be a quite late, but
that may be a quite late,
but still, i've had the task and i found this module
that helps - http://drupal.org/project/taxonomy_redirect