I've got views installed and CCK. I've used CCK to create a new node type called Software download. One of the fields in the CCK node type is user reference. How do I show a block to logged in users that displays nodes from the CCK node type (Software download) that is referenced to their uid or username?

Views or custom php snippet?

Comments

GN’s picture

Was CCK installed smoothly for you?
I have a problem with its installation under 4.7.0 --
(1) the database tables are not created automatically when I enable the module, and
(2) even if I create these tables manually using the db_queries from the content.install file, I get an empty page for "content types" administration.
http://drupal.org/node/63565

Mojah’s picture

I found that the first time I installed it gave me a few bugs. But the 2nd time I installed, I enabled content.module and then all the other field modules one by one. This seemed to work. I am using the cvs version which was recently updated.

Schoonzie’s picture

I would like to do a similar thing. Unfortunately I don't think (with the current 4.7 modules) there is a way to do it with views

For now, I have used a PHP snipped

<?php

global $user;
if ($user->uid) {
	$node_type = "content-private_page";
	$list_no = 100;
	$sql = "SELECT node.title, node.type, node.nid FROM node, node_data_field_user userref WHERE node.type = '$node_type' AND userref.field_user_uid='$user->uid' AND userref.nid=node.nid LIMIT $list_no";
	$output .= "<ul>";
	$result = db_query($sql);
	while ($anode = db_fetch_object($result)) {
	$output .= "<li>".l($anode->title, "node/$anode->nid")."</li>";
	}
	$output .= "</ul>";
	print $output;

}
if (!$user->uid) {
    return "You must be logged in to view this page.";
}
?>

I have used a very similar snippet for the block. If you find a way of doing this using views, I would love to know.