Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#38 | 917460.38.twitter_pull.boxes_.patch | 2.56 KB | joachim |
#24 | 917460-add-twitter-pull-box-8.patch | 2.84 KB | jec006 |
#23 | 917460-23.twitter_pull.boxes_.6.patch | 2.56 KB | joachim |
#22 | 917460-22.twitter_pull.boxes_.7.patch | 2.87 KB | joachim |
#20 | twitter_pull-add_box-drush2.patch | 2.71 KB | jec006 |
Comments
Comment #1
danielinniss CreditAttribution: danielinniss commentedAdded a block and some extra features.
Settings page to change cache length and disable CSS style sheet
Comment #2
danielinniss CreditAttribution: danielinniss commentedpatched install file
Comment #3
ZenDoodles CreditAttribution: ZenDoodles commentedGreat 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
I'd be happy to attempt a re-roll if it doesn't do the trick for you.
Thanks!
Comment #4
irakli CreditAttribution: irakli commentedI 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!
Comment #5
ccarigna CreditAttribution: ccarigna commentedI 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.
Comment #6
Juan C CreditAttribution: Juan C commentedThanks cwc.
Comment #7
irakli CreditAttribution: irakli commentedScreenshots look awesome. Can't wait to review.
Thanks, @cwc!
Comment #8
ccarigna CreditAttribution: ccarigna commentedI 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).
Comment #9
franzkewd CreditAttribution: franzkewd commentedsubscribe
Comment #10
mrfelton CreditAttribution: mrfelton commentedNeed this for D7 too. Is the policy not to develop for D7 first, and then backport?
Comment #11
mrfelton CreditAttribution: mrfelton commentedHere is the patch at 5 ported to D7.
Comment #12
mrfelton CreditAttribution: mrfelton commentedMarked #1126892: Configuration add-on module as a duplicate.
Comment #13
mrfelton CreditAttribution: mrfelton commentedI 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
Comment #14
franzkewd CreditAttribution: franzkewd commented+1 on #13
Comment #15
FreeFox CreditAttribution: FreeFox commentedpatch #11 was exactly what I needed. I would be very happy when this patch is committed.
Good job !!!
FreeFox
Comment #16
jec006 CreditAttribution: jec006 commentedHi,
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.
Comment #17
Juan C CreditAttribution: Juan C commentedThanks jec. Do you have a patch for 6.1.dev as well?
Comment #18
jec006 CreditAttribution: jec006 commentedI don't right now Juan - I don't think it should be much different though - i'll look into it.
Comment #19
jec006 CreditAttribution: jec006 commentedAdded a version of the patch which will work with drush make
Comment #20
jec006 CreditAttribution: jec006 commentedThe last patch had a couple errors in it - including removing the .install file from the .info file's list of files.
new patch attached.
Comment #21
joachim CreditAttribution: joachim commentedI 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'
Comment #22
joachim CreditAttribution: joachim commentedHere's the patch from 20 rerolled with an improved form description, whitespace fixes, and the form titles in sentence case rather than title case.
Comment #23
joachim CreditAttribution: joachim commentedAnd here's the same patch backported to D6.
Comment #24
jec006 CreditAttribution: jec006 commentedPatch 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.
Comment #25
jec006 CreditAttribution: jec006 commentedI committed the patch from #24
Thanks Joachim for the assist
Comment #26
jec006 CreditAttribution: jec006 commentedComment #27
mrfelton CreditAttribution: mrfelton commentedHmm. 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
Comment #29
bkoether CreditAttribution: bkoether commentedI created a Bean plugin for Twitter Pull here: http://drupal.org/project/bean_twitter_pull.
Feedback is welcome.
Comment #30
jec006 CreditAttribution: jec006 commentedThats 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
Comment #31
bkoether CreditAttribution: bkoether commentedI 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?
Comment #32
mrfelton CreditAttribution: mrfelton commentedI 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.
Comment #33
jec006 CreditAttribution: jec006 commentedOk, that makes sense.
We can have a related modules section or some such.
Comment #34
jec006 CreditAttribution: jec006 commentedComment #36
frichman CreditAttribution: frichman commentedReally 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.
Comment #37
joachim CreditAttribution: joachim commentedAny chance this could be committed to the D6 branch?
Comment #38
joachim CreditAttribution: joachim commentedHere's that patch for D6 again. On D6 the check_plain() is needed on the title.
Comment #39
joachim CreditAttribution: joachim commentedCommitted to 6.x-2.x.
Issue #917460 by ccarigna, mrfelton, jec006, joachim: Added twitter pull block type for Boxes module.