Come together with the global Drupal community in Rotterdam, 28 Sept – 1 Oct 2026. Sessions, contribution, connection, and Early Bird savings until 8 June.
Do you mean disallowed nodes because of user permissions ? If so, you can correct this using the SQL query. If you need to access an array of the roles of the current user using autocompletion, you can change:
In search_autocomplete.module:
change lign 24 to: global $language, $user;
change lign 52 to:
Even with this, I must confess the SQL statment will not be easy-peasy. That's why I'm working on a version to use VIEWS module to easily create the suggestions without using SQL. I hope to finish this new feature soon.
Yes, I've meant disallowed nodes because of user permissions. I've understood your idea and did some another changes for it works. In search_autocomplete.modile line 24 changes to:
global $language, $user;
To line 56 add (without checking for $query really has ':roles' placeholder it doesn't work):
SELECT n.title FROM {node} n
INNER JOIN {node_access} na ON (na.nid = n.nid)
WHERE n.status = 1 AND n.title LIKE :like_word
AND na.realm = 'nodeaccess_rid' AND (na.grant_view = 1 OR na.grant_update = 1)
AND na.gid IN (:roles)
I'd love to have this feature added, and making the option available via the UI is always preferred over module hacks. I'm using the Restrict Node Page View module to restrict direct access to the full node for certain content types, but you can still type in a restricted node title and see it come up in the autocomplete list.
Great module, by the way, thank you for all your work!
Comments
Comment #1
dom. commentedHi!
Do you mean disallowed nodes because of user permissions ? If so, you can correct this using the SQL query. If you need to access an array of the roles of the current user using autocompletion, you can change:
In search_autocomplete.module:
change lign 24 to:
global $language, $user;change lign 52 to:
This will offer you the :roles placeholder.
Even with this, I must confess the SQL statment will not be easy-peasy. That's why I'm working on a version to use VIEWS module to easily create the suggestions without using SQL. I hope to finish this new feature soon.
Thanks for using this module,
Regards,
Miro.
Comment #2
DizelGenerator commentedHi Miroslav!
Thanks for your answer!
Yes, I've meant disallowed nodes because of user permissions. I've understood your idea and did some another changes for it works. In search_autocomplete.modile line 24 changes to:
To line 56 add (without checking for $query really has ':roles' placeholder it doesn't work):
The SQL statement for using this workaround:
Comment #3
dom. commentedThanks a lot for sharing! I'm sure it will help others!
I will definitely improve the module to produce the JSON callback suggestions using views cause this is not easy enough for end-user.
Miro.
Comment #5
OldAccount commentedI'd love to have this feature added, and making the option available via the UI is always preferred over module hacks. I'm using the Restrict Node Page View module to restrict direct access to the full node for certain content types, but you can still type in a restricted node title and see it come up in the autocomplete list.
Great module, by the way, thank you for all your work!