show node title to unregistered users
I'm using content access module to restrict c开发者_StackOverflow社区ertain nodes and node types for un-registered users.
But I would like to create a view where unregistered users can also see titles of those restricted nodes.
How can I do this ?
I haven't used this personally, but I just saw it pop up in the drupal.org module feed a few days ago, and it should help: http://drupal.org/project/views_ignore_node_permissions
ok if you just want to echo the node title in php (with in the node body ) enable php then :
<?php
if (arg(0) == 'node' && is_numeric(arg(1))) $nodeid = arg(1);
$node = node_load($nodeid);
print $node->title;
?>
Blockquote
and you are done
If you want to restrict access to some fields and not to others, you really should be using permissions per field. I assume all fields are built with CCK, so just enable permission for the content-type, but disable for all fields.
That way, only the title is visible. I don't think you can disable permissions for the standard body field, but I always use a CCK text-area for that anyway, it's alot easier also for css since the standard body field isn't wrapped in default node printing.
You can write a simple module for this, which does the following:
- query the node titles you want to show (called by hook_menu)
- theme the result (hook_theme)
- display the result (hook_block)
in the hook_perm you can create a new permission who you would like to show the node titles, if it is for everybody, just use 'access content'.
The solution is here:
In the views "Query options"-settings it's possible to set "Disable SQL rewriting" ("Disabling SQL rewriting will disable node_access checks as well as other modules that implement hook_query_alter().") which afaik makes this module unneeded with the latest views version.
精彩评论