I'm working on a site that will include job listings. I've used CCK to create a Job content type that includes the requisite information (employer, contact information, etc.). To allow users to sort and search through the listings, I have a View that displays a subset of the job information, with the title linking to the full listing. What I'd like is to make the full listing members-only (login required), but make the View accessible to anonymous users, so that anonymous users can see that titles and employers, but not the contact information and so forth. I've installed the Content Access module, and restricted views of the Job type to members only, but when I do that, they also disappear from the View. Is there some way to have parts of the node visible in the View for anonymous users without allowing access to the whole node?

Comments

cog.rusty’s picture

A first idea, there is the http://drupal.org/project/cck_field_perms module. I don't know how good it is, but in theory you could permit access to the fields which you display in the view and protect the fields which you don't.

Another idea is to use http://drupal.org/project/path_access, if the (aliased) paths of your full nodes are consistent enough to allow it.

celloandy’s picture

The second option probably won't cut it, since there will be enough entries that managing aliases for all of them will be unrealistic. The first option is better, though. It seems to be close to what I want, though my one issue is that when users try to see the nodes, they just see fewer fields, and it's not obvious that more content is available if they log in. It'd be cool if, when they clicked on the link from the View, they got an Access Denied page, instead, as I'm using a module that slaps a login prompt on that page. This is a step in the right direction, though, so thanks!

cog.rusty’s picture

About the path_access option, I was thinking of pathauto. If those node pages have their own node type, then pathauto could give them a path pattern which you could protect.

Another idea is to use a different node type for the teaser fields, among which a nodereference field to the real thing (another node type). A problem here is how to make it easy to duplicate some content in the teaser node. Maybe one of the cloning modules can help.

I just remembered http://drupal.org/project/premium which is very close to what you want but I don't know how flexible it is.

celloandy’s picture

Ugly hack of the century, but what I ended up doing, which works alright: I added the Computed Fields module, and in the display code of a computed field, added a check to see if the user is logged in, and if not, call drupal_goto to send them to the login form. I left the field perms module installed, to be on the safe side, so malicious anonymous users shouldn't be able to get any content they wouldn't otherwise be able to access.

Thanks, again, for your help.

cog.rusty’s picture

If it works then all is good. Does that computed field tell the visitor what to expect? It seems a hard punishment to send them to the login form just for clicking on a link.

celloandy’s picture

I'm doing a drupal_set_message first, so there's some explanation on the login page. I'll probably add messaging to the header of the view, as well.

jonfhancock’s picture

I would be interested to see your code for the computed field.

I'm doing something very similar.

mlondon77’s picture

I'd just like the link to the CCK page visible in the menu block, but when an anonymous user clicks it, it'll prompt them to log in.

Does anyone have any ideas? I've been trolling this site for answers, but can't seem to find an easy one.

I'm a newbie, using Drupal 5.

Thanks.