Views Modules to Show on Tags for Published Nodes

ajwilson - June 12, 2009 - 03:28

Hi,

I am using Drupal 6 to host a blog. It's all working fine. Free tagging is enabled to create tags for the blog entries. Because of the workflow we have created a number of blog entries which are not yet published.

We have a block which was created using Views 2 to show all the tags and to link to the relevant taxonomy page. This is all working fine. The challenge is that we want to only show tags for nodes which are both published and only for blog entries.

Using Views, this should be easy.

We

1. create a view displaying items of type node,
2. filter on node type and node published,
3. select just the taxonomy Term to display
4. create the block view and activate the block

All works fine, except that if a taxonomy term is repeated we get multiple entries.

Using Distinct doesn't work because the query is build from the node id (nid) and note the taxonomy term (tid).

If we work with items of type taxonomy, then I can't see how to get access to the node fields to filter just the required nodes.

I know that the final SQL statement I need is as follows:

SELECT
DISTINCT term_data.name AS term_data_name,
term_data.vid AS term_data_vid,
term_data.tid AS term_data_tid
FROM node node
LEFT JOIN term_node term_node ON node.vid = term_node.vid
LEFT JOIN term_data term_data ON term_node.tid = term_data.tid
WHERE (node.type in ('blog')) AND (node.status <> 0)

It is identical to the one created by Views, only the "node.nid AS nid" is removed. So my next step is to create a custom block. That will create unnecessary upgrade problems and the views approach is so close.

Yes I have tried grouping by Taxonomy term, however they just repeats the number of terms.

Can anyone provide guidance to what I am missing and how to get this result?

Thanks.

How are you doing "3. select

nevets - June 12, 2009 - 04:10

How are you doing "3. select just the taxonomy Term to display", a views argument or filter and which one?

Using the field

ajwilson - June 13, 2009 - 05:47

Just using the Field to select the "Taxonomy: Term". No arguments are defined and the only filters are for published nodes and type of blog.

It sounds like you want to

nevets - June 13, 2009 - 14:15

It sounds like you want to use "Taxonomy: All terms" instead of "Taxonomy: Term"

Taxonomy: All terms gives the same result as Taxonomy: Term

ajwilson - June 18, 2009 - 07:23

Thanks for the suggestion.

Taxonomy: All terms gives the same result as Taxonomy: Term. We still end up with duplicate entries.

There must be some way to just get the tags for only nodes that are published.

Interestingly my searches took me to the tagadelic module which has the same issue. It shows the tags for all nodes and there is no way to limit it to just showing the tags for published nodes. There is a bit of a discussion about this over there.

 
 

Drupal is a registered trademark of Dries Buytaert.