First off - thanks for bringing this functionality to Drupal 7 - much appreciated.
I have the module installed on a site I'm developing right now, but there is a small issue with it that I was able to fix with a tiny code change, and I'm hoping you'll consider it for inclusion in the module.
Currently, when this module hides part of a node from a non-privileged user, it also hides it from the search index. This means that the search system is only indexing what is displayed to non-privileged users.
I think it would be helpful if the search index was able to access as much as the node as is specified by the current view mode. If there is a custom "search index" view mode, then it would use that, otherwise it would use the default.
I was able to make this happen by changing one line of code in nopremium.module:
Before:
/**
* Implementation of hook_node_view_alter().
*/
function nopremium_node_view_alter(&$build) {
$node = $build['#node'];
if (($build['#view_mode'] != 'teaser') && $node->premium && !nopremium_access_full_content($node)) {
nopremium_alter_node($build);
}
}After:
/**
* Implementation of hook_node_view_alter().
*/
function nopremium_node_view_alter(&$build) {
$node = $build['#node'];
if (($build['#view_mode'] != 'teaser' && $build['#view_mode'] != 'search_index') && $node->premium && !nopremium_access_full_content($node)) {
nopremium_alter_node($build);
}
}Please considering accepting this patch. At the very least, I think this should be included as an option.
Thanks,
-mike
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | searchindex-1274378-2.patch | 544 bytes | ultimike |
Comments
Comment #1
anrikun commentedThanks!
If you have some time, could you please turn this into a real patch?
Also, a question:
After applying the patch and indexing, what happens when a non-privileged user try to search some keywords that are in the premium (hidden to non-privileged users) part? Do results from the premium part show up?
Can you please test this and tell me?
Comment #2
ultimikeA proper patch is attached.
With the patch applied, premium content is not displayed in the search results - it is only available for searching via the search index.
Thanks,
-mike
Comment #3
anrikun commentedThanks!
Comment #4
anrikun commentedCommitted to 7.x-1.x. Thanks!