I don't think we need a "glue" module to utilize a block for twitter_pull.

Here is a drupal block for creating one user's twitter account. With a bit more code we could easily use it to include x amount of users. Here is the twitter_pull_block hook:

<?php
function twitter_pull_block($op='list', $delta = 0, $edit = array()) {
 switch ($op) {
   case 'list':
     $blocks[0]['info'] = t('Twitter pull block');
     return $blocks;

   case 'configure':
     $form['twitter_pull_twitter_account'] = array(
         '#type' => 'textfield',
         '#title' => t('Twitter account to pull'),
         '#default_value' => variable_get('twitter_pull_twitter_account', ''),
         );
     return $form;

   case 'save':
     if(strpos($edit['twitter_pull_twitter_account'],'@')===FALSE){
       $edit['twitter_pull_twitter_account'] = '@' . $edit['twitter_pull_twitter_account'];
     }

variable_set('twitter_pull_twitter_account',$edit['twitter_pull_twitter_account']);
     break;

   case 'view':
     $twitter = variable_get('twitter_pull_twitter_account','@unknown');
     $block['title']=t($twitter . "'s Feed");
     $block['content'] = twitter_pull_render($twitter, '', 5);
     return $block;

 }//switch
}
?>

Also, a

 variable_del('twitter_pull_twitter_account');

will need to be added to the twitter_pull_uninstall() function.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

danielinniss’s picture

FileSize
3.34 KB

Added a block and some extra features.
Settings page to change cache length and disable CSS style sheet

danielinniss’s picture

FileSize
556 bytes

patched install file

ZenDoodles’s picture

FileSize
4.83 KB

Great module. With this patch it is exactly what we needed.

With some nudging, these patches almost worked for me. There was a missing bracket at the end, likely due to the confusing nested switch statements. I fixed it, cleaned up a bit, and rolled a proper patch. Well, I hope it's a proper patch. It's the first one I've rolled w/ git. Applies cleanly with

patch < 917460_provide_block.patch

I'd be happy to attempt a re-roll if it doesn't do the trick for you.

Thanks!

irakli’s picture

Status: Active » Needs review

I agree. We still need hook_twitter_pull_blocks() for more advanced integrations, but for simple stuff something like the patch attached would be VERY useful.

Need to review and we also need a D7 version :(

I am about to release a new version (alas, without this, sorry) so if somebody can please re-roll after the new release, that would definitely help prioritize this issue.

Many thanks for working on this!

ccarigna’s picture

Version: 6.x-1.1 » 6.x-1.2
FileSize
34 KB
18.91 KB
12.76 KB

I was looking for the ability to easily add as many twitter blocks as you want. I've been working on this, and so far here is the result - I've added an admin interface under Site Building > Twitter Blocks. Once you create a block, you can then add it to your site under the normal Site Building > Blocks area.

This is a start, and feedback on this would be appreciated. I think it makes it much easier to add Twitter feed blocks (especially for people who aren't developers).

Note that after patching, you will have to run update.php.

Juan C’s picture

Thanks cwc.

irakli’s picture

Screenshots look awesome. Can't wait to review.

Thanks, @cwc!

ccarigna’s picture

I was reviewing my own code, and noticed that the title being set is commented out (I was trying to figure out how the title and name fields were being used), though apparently things still work. (This is in the twitter_pull_block_data function).

Also, I tested this while also included a twitter block created in another module using the hook, and noticed that the blocks I had set switched around with the hooked one. To fix this, I assign the $data array keys in that function to the delta value, so that the block data is retrieved correctly in the twitter_pull_block() function.

I also added extra text to the delta from hooked calls to avoid any collisions, but now I think it may not be necessary (and I shouldn't be modifying the delta value given by another module).

franzkewd’s picture

subscribe

mrfelton’s picture

Need this for D7 too. Is the policy not to develop for D7 first, and then backport?

mrfelton’s picture

Version: 6.x-1.2 » 7.x-1.x-dev
FileSize
14.8 KB

Here is the patch at 5 ported to D7.

mrfelton’s picture

mrfelton’s picture

I think it would be a good idea to consider moving this additional functionality to a submodule (twitter_blocks_ui or something like that), like what @chales had done in #1126892: Configuration add-on module

franzkewd’s picture

+1 on #13

FreeFox’s picture

patch #11 was exactly what I needed. I would be very happy when this patch is committed.

Good job !!!
FreeFox

jec006’s picture

Hi,
Taking this in a slightly different direction - I've added a boxes plugin to the module which will allow you to create many twitter_pull blocks, each with a different configuration (i.e. different search).

Patch is attached.

Juan C’s picture

Thanks jec. Do you have a patch for 6.1.dev as well?

jec006’s picture

I don't right now Juan - I don't think it should be much different though - i'll look into it.

jec006’s picture

Added a version of the patch which will work with drush make

jec006’s picture

The last patch had a couple errors in it - including removing the .install file from the .info file's list of files.

new patch attached.

joachim’s picture

Status: Needs review » Needs work

I can report that the only change to make this work on D6 is to remove the parameter from the options_form() function declaration.

This new approach is really nice.

The only change I'd recommend is to clean up the wording a bit on this and also give examples:

'#description' => t('The twitter user or hashtag to build this box off of.'),

It's worth mentioning here also that lists are supported, eg '@user/list'

joachim’s picture

Status: Needs work » Needs review
FileSize
2.87 KB

Here's the patch from 20 rerolled with an improved form description, whitespace fixes, and the form titles in sentence case rather than title case.

joachim’s picture

And here's the same patch backported to D6.

jec006’s picture

Patch from 22 except I removed the check_plain on the title of the box as this was escaping escaped characters, ect. repeatedly. I think that boxes actually does the check plain for us.

jec006’s picture

I committed the patch from #24

Thanks Joachim for the assist

jec006’s picture

Status: Needs review » Fixed
mrfelton’s picture

Hmm. I would have preferred to see this implemented as a Bean plugin. Bean is a lot more powerful and flexible than Boxes. http://drupal.org/project/bean

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

bkoether’s picture

I created a Bean plugin for Twitter Pull here: http://drupal.org/project/bean_twitter_pull.
Feedback is welcome.

jec006’s picture

Status: Closed (fixed) » Needs review

Thats awesome. I'd be open to possibly pulling this into the twitter pull module if that is your desire and people think that wouldn't create too much extra stuff

bkoether’s picture

I don't know if it would be a good idea to pull the whole functionality into the twitter_pull module itself because of the added dependencies that the Bean module brings. Maybe if it would be a sub-module?

mrfelton’s picture

I would be inclined to keep the bean plugin as a standalone project. Just add a link to it in the twitter_pull project page and in the documentation to make people aware of it.

jec006’s picture

Ok, that makes sense.

We can have a related modules section or some such.

jec006’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

frichman’s picture

Really glad I found this post. I installed Bean as well as entity to get everything running without a bit of code and with as many different blocks as I want. I think it would be great to have something about this process written in the documentation somewhere, I would be willing to draft a short summary of the steps.

joachim’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev
Status: Closed (fixed) » Needs review

Any chance this could be committed to the D6 branch?

joachim’s picture

Here's that patch for D6 again. On D6 the check_plain() is needed on the title.

joachim’s picture

Title: Twitter_pull block » support for Boxes module
Version: 6.x-1.x-dev » 6.x-2.x-dev
Status: Needs review » Fixed

Committed to 6.x-2.x.

Issue #917460 by ccarigna, mrfelton, jec006, joachim: Added twitter pull block type for Boxes module.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.