문제

When writing a module, how can I perform an operation every time a node is viewed by a user?

도움이 되었습니까?

해결책

You can use hook_nodeapi() in Drupal 6 and check that the $op argument is 'view'. In Drupal 7, this has been changed to hook_node_$op() where $op is replaced by the value you would have checked for in the Drupal 6 version. So you would use hook_node_view(). For more details about the changes from Drupal 6 to Drupal 7 see http://drupal.org/update/modules/6/7#remove_op.

다른 팁

Alternatively you could use Drupals Trigger module which has a 'When content is viewed by an authenticated user' trigger by default.

You can create an Action through /admin/settings/actions, or write your own based on the information at http://drupal.org/documentation/modules/trigger. You will also find modules that have predefined triggers and actions.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 drupal.stackexchange
scroll top