i have created a custom view. its just showing nodes of a particular type. Now i want to do something with it. I am writing a SQL query:
global $user; $query = db_select('challenges','c'); $query->join('node','n','n.nid = c.cid'); $query->join('field_data_body','f','n.nid = f.entity_id'); $query->join('field_data_field_challenge_pic', 'fp','n.nid = fp.entity_id'); $query->join('file_managed','fm','fp.field_challenge_pic_fid = fm.fid'); $query->fields('n',array('nid','title','created')) ->field('f',array('f','body_value')) ->field('fp',array('fm','uri')) ->condition('c.cid','$user->uid','='); $result = $query->execute();
Where should i place this query in my custom module and how can i get my view to display this? I tried writing this code in a tpl file for the view and then did print_r and render() but no effect. I think it should be done through views.