Advertisement
asanchez75

drupal/views

Aug 17th, 2013
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. //
  2. <?php
  3. // $Id: custom_views.module,v 1.272.2.1 2009/04/27 12:25:24 goba Exp $
  4.  
  5. function custom_views_views_pre_execute(&$view) {
  6.  
  7. if($view->name=="SiteActivity")
  8. {
  9. $view->build_info['query']=
  10. "
  11. SELECT node.nid AS nid,
  12. users.picture AS users_picture,
  13. users.uid AS users_uid,
  14. users.name AS users_name,
  15. node.type AS node_type,
  16. node.title AS node_title,
  17. node.created AS node_created
  18. FROM node node
  19. INNER JOIN users users ON node.uid = users.uid
  20. WHERE (node.status <> 0)
  21.  
  22. UNION
  23.  
  24. SELECT comments.cid AS cid,
  25. users_comments.picture AS users_comments_picture,
  26. users_comments.uid AS users_comments_uid,
  27. users_comments.name AS users_comments_name,
  28. node_comments.type AS node_type,
  29. comments.subject AS comments_subject,
  30. comments.timestamp AS comments_timestamp
  31. FROM comments comments
  32. LEFT JOIN node node_comments ON comments.nid = node_comments.nid
  33. LEFT JOIN users users_comments ON comments.uid = users_comments.uid
  34. WHERE (node_comments.status <> 0)
  35. ORDER BY node_created DESC
  36.  
  37. ";
  38. //count_query determines the pager. Do this so the right item count is returned. If you don't do this, you'll only return the query amount
  39. $view->build_info['count_query']=$view->build_info['query'];
  40.  
  41. }
  42. }
  43.  
  44. /**
  45. * This module is Views 2.0 enabled.
  46. * Implementation of hook_views_api().
  47. */
  48. function custom_views_views_api() {
  49. return array('api' => 2.0);
  50. }
  51.  
  52. ================================================
  53. SELECT total.*
  54. FROM
  55. (SELECT r.realname AS node_title, r.uid AS nid, r.created AS node_created
  56. FROM
  57. realname r
  58. WHERE (r.uid <> '0') UNION ALL SELECT node.title AS node_title, node.nid AS nid, node.created AS node_created
  59. FROM
  60. node node
  61. ORDER BY node_created DESC) AS total WHERE total.node_title LIKE '%admin%'
  62. LIMIT 10 OFFSET 0
  63.  
  64. ==================================================
  65. * See https://drupal.org/node/409808
  66. * https://drupal.org/node/748844
  67. * http://sethsandler.com/code/drupal-6-creating-activity-stream-views-custom-sql-query-merging-multiple-views-part-1/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement