1
votes

I am a junior developer who has come across Drupal for the first time, and am enjoying my experience.

A project I am working on is retrieving tweets for given keywords/hashtags, storing them as a custom content type/node, and then displaying them in a view. I am able to retrieve tweets (via the API + TwitterOauth) and store them, but am having trouble thinking how to display them. My project is similar to the tutorial 'Saving Twitter Tweets to Nodes in Drupal 7 with hook_cron', and the way I would like to display my tweets is in the tutorial demo at http://aap.cornell.edu/news-events.

I have read the documentation, and have googled for help, but am finding it more difficult than first thought (I would rather have done this in Laravel, but Drupal is the requirement). I appreciate any help/feedback on how to achieve a solution, and general advice for a newbie Drupal developer facing similar problems :).

1
Did you even tried to start making a view? Start, select to display content, select your twit custom content type, save the view. Then edit it, set the filters...Yell if you face some problems, but start at least.MilanG

1 Answers

1
votes

After further learning and testing, I managed to get it figured out - thanks to http://websmiths.co/blog/drupal-views-tutorials-exporting-views-code. I didn't think it was this easy, but it more or less helped my achieve my primary objectives. There's still a couple of extra things to do, but I believe I have the gist of it now.

One thing I found out, after successful view implementation, was that the new view wasn't immediately available in Admin > Structure > Views. I know you can clear the cache in Configuration > Development > Performance (which enables the new view to be visible), but I need the view to be immediately available upon installation. Further research of caching showed me this can be done very simply - by calling db_query("DELETE FROM {cache};"); in the hook_install in your .module. An example of what I have here is below:

/**
 * Implements hook_install().
 */
function mymodule_install(){
    _initial_twitter_tags_db_populate();
    node_types_rebuild();
    $types = node_type_get_types();
    node_add_body_field($types['tweet']);
    add_custom_fields();
    db_query("DELETE FROM {cache};");
}