It would be great to have a way of linking a twitter account to a node, for it to post it's updates to.

Usage: I have a Artist Manager account. They can setup multiple content profiles (Artists).

Currently when they add pics, songs, blogs, etc they can assign it to one of the content profiles (nodes).
It would be nice to assign a twitter account to a content profile (or any node), and have the tweets displayed on that node.
Because obviously in my case every artist has their own twitter.

Is there a way this can be accomplished with the current module, and perhaps a computed field?

Comments

Todd Young’s picture

Very Interested, subscribing...

Exploratus’s picture

subscribe...

steeph’s picture

I know it's not what you wanted, but perhaps it helps.
http://www.foggyperspective.com/twitter-widget-using-the-computed-field-...

XiaN Vizjereij’s picture

Very interested as well.

I have a lot artists ( its a content type ) nodes as well and i want to attach a different twitter account to every artist node and use all the awesome features of the Twitter Module ( full views integration, actions and so on ). However creating a "user" for all those artists is not possible and using a Feeds workaround is also not very doable ( the artists content type already has an feed importer attached to them and you can't use more than one ).

So a CKK or FieldAPI Field for Drupal 7 would be extremly nice :)

mogop’s picture

I was thinking for something similar could you provide link for your site if it's online?
Thanks

jwilson3’s picture

Version: 6.x-2.6 » 6.x-3.x-dev

Having a specific field type where you can simply save a twitter id, or search string with perhaps a handfull of different field formatters, eg to display the recent tweets (in a twitter widget) would be really useful.

This could be a useful direction for the Drupal 7 rewrite (#780712: Port twitter to Drupal 7), where building profiles using entity and profile2 is going to be a more common pattern. Since there isn't a 7 branch yet, I'm updating this to the latest d6 branch.

gapple’s picture

Component: User interface » Code
Assigned: Unassigned » gapple

I've created a simple module that uses the CCK Text field type to store Twitter usernames, hashtags, and/or search terms (I don't think a custom field type is really necessary). What can be stored is selectable through the widget settings.

Github: https://github.com/gapple/twitterfield
Drupal Sandbox: http://drupal.org/sandbox/gapple/1180620

As mentioned on the sandbox page, I would like to add formatters to display the value as a link or use Twitter Pull to show a feed.

I would especially appreciate a review on if the validation logic makes sense.

jwilson3’s picture

Component: Code » User interface

I created a sandbox module that essentially provides this ability with a plain CCK Text field, using a custom field formatter.

Twitter Field Widget

It's built for Drupal 7, but a backport to D6 should be trivial enough.

jwilson3’s picture

Assigned: gapple » Unassigned

Woah. thats crazy. @gapple: You beat me to it, and your's is quite a bit more complete than mine :) cheers.

gapple’s picture

Component: User interface » Code

Well, I've got a widget, you've got a formatter. Put them together and we're on our way to a module!

I'll start with a simple link formatter first, but will take a closer look at your code and try backporting it for my sandbox project.

Edit: link formatter is committed to sandbox project.

gapple’s picture

@jwilson3
I pulled the commits from your module and used a merge to backport your features as a 'Twitter Widget' formatter for my module. I really like being able to use a template file for rendering.

My sandbox module also supports lists now (e.g. @gappleca/drupal).

gapple’s picture

I've submitted an application to be able to promote my sandbox project to a full module: http://drupal.org/node/1182046

I would appreciate any reviews and feedback in order to help the application along! :)

jwilson3’s picture

Nice work pulling my work in... and expanding it to work with both searches and profiles (what about faves?).

I really like being able to use a template file for rendering.

I agree, especially when the twitter widgets let you "build your own widget" on their site... it's easier to copy and paste the chunk that defines the colors you want to use (more or less, i mean, you have to watch out for the passed in values from php, obviously).

good work gapple.

michaek’s picture

Sorry, but pasting in Twitter's widget isn't really relevant to this module.

steeph’s picture

It's spam. The same was pasted on other issues and forum topics.

michaek’s picture

Yep, but I don't know of a way to flag someone (or their posts) as spam, unfortunately.

michaek’s picture

Ok. Issue added for webmasters. #1190704: Spammer: katehsu

damienmckenna’s picture

@gapple, @jwilson3: why don't you combine your efforts into one module with separate functionality for D6 and D7?

gapple’s picture

I think the only thing preventing me from pushing a 7.x branch with @jwilson's work into my module is changing the namespace to match.

After that I'll need to get familiar with the Field API to port the extra functionality in my 6.x branch.

cookiesunshinex’s picture

This is EXACTLY what I have been looking for.

Subcribing.

leahmd’s picture

Subscribing.

michaek’s picture

I might be interested in getting twitter_field rolled in as a submodule, but I would rather use cron and the API to load tweets than to display them with Twitter's widget.

gapple’s picture

I would be very happy to get integration with Twitter module, and would appreciate any help. (Though I'm tied up in other projects at the moment.)

I think it may be better to have twitterfield stand on its own though, since it can work without twitter module. Displaying a link or using Twitter's widget are simple options for people who don't need or want to bother with setting up twitter module, and I would like to work with twitter_pull module as an alternate display option as well.

XiaN Vizjereij’s picture

I think most of the people here want to attach twitter feeds which follow the twitter module route ( e.g. creating nodes from the tweets, make them views aware and so on ) to cck content types. Until #634462: Attach multiple importers to one content type (in D6) gets resolved there is no way to achieve that at the moment.

If you just want to display tweets you could use twitter_pull or a php field with the twitter embed code copied in or use a computed field which calculates the twitter embed code based on the value ( the twitter name ) the user entered.

michaek’s picture

This module now makes it much easier to display Tweets (OAuth is not longer required for read-only use of the API), so I think the Twitter module is as simple as twitter_pull, and almost certainly the right way to go.

This module has made things really difficult in the past, but I'm hoping to focus on the most common use cases and make them as easy as possible. I think we're definitely getting close to there not being much "bother" associated with most use cases. :)

I'm not wild about the Twitter embed code, because it relies on Javascript, often causes page re-rendering once tweets load, and puts another layer between you and styling Tweets the way you might like to.

gapple’s picture

I understand and agree with the downsides, but I don't think they are reason to not make the Twitter JS widget available to those who may want to make use of it anyways.

XiaN Vizjereij’s picture

Which is what http://drupal.org/project/twitter_pull does, or? Else use a Computed Field or a text field with php input filter and copy and paste the embed code from twitter there.

I don't really see why this needs to be an own module, since its really easy to accomplish anyways :)

michaek’s picture

I agree with XiaN that the Twitter widget is simple enough that there's little reason to provide a module for it. However, pulling tweets from Twitter's API, storing them in the database, and providing views for their display is just the sort of thing this module is for. :)

However, as gapple says, because it's so simple there's little harm in making it available as a display option. It's more complex if we expect the module to not load tweets for accounts that are only displayed with the Twitter widget.

gapple’s picture

A text field where users could paste the embed code would be a bad idea, since it would open up any and every JS-based security exploit. Using PHP-Filter so that they could paste in the twitter_pull code would be worse.
A computed field doesn't offer the validation options possible through my twitterfield module, and I think is quite clearly a more complex option to set up.

I agree that the Twitter Widget is simple enough to not require a module if you're using it in a limited capacity, and the input method is limited to trusted and knowledgeable users. That is not the case for a user-generated content site where many users will input twitter handles for display.

If it would be required to pull in tweets via the API and store them in the database in order to integrate with twitter module, I think that is an even better case for keeping the module separate. On my site I really don't want to be pulling in tweets from hundreds of twitter feeds, storing them in my database, and filtering them for every profile page view.

cookiesunshinex’s picture

This module was very simple for me. I was able to use it pretty quickly. Whereas, the twitter module did not do exactly what I wanted and/or was way OVERKILL.

Perhaps, instead of downplaying gapple's work here, maybe you could write better documentation for twitter_pull on an actual use case. The documentation is very sparse, and I honestly couldn't figure out how to get it to work. No response in the issue queue either.

"If it would be required to pull in tweets via the API and store them in the database in order to integrate with twitter module, I think that is an even better case for keeping the module separate. On my site I really don't want to be pulling in tweets from hundreds of twitter feeds, storing them in my database, and filtering them for every profile page view."

I 100% agree with gapple on this.

gapple’s picture

@cookiesunshinex
Do you mean twitter module, not twitter_pull?
I found twitter_pull to be very simple and straightforward, with plenty of documentation on the project page. If you haven't looked at my twitterfield module in a little while, I added a formatter that uses twitter_pull on July 8th, and it was very simple to do. I will have to look into if something similar is possible with twitter module.

(I would also very much appreciate your support on my project application #1182046: TwitterField)

michaek’s picture

@cookiesunshinex:

If you're talking to me (the maintainer), I'm definitely not downplaying @gapple's work. In fact, I want to roll it into the module! I merely want to add support for storing tweets in the database, as that's one of the primary patterns of this module. However, I think @gapple's use case of having many Twitter accounts that you're not interested in mirroring locally is a good one, and worth taking into consideration. I definitely think providing an option to use Twitter's widget for displaying tweets is worth implementing for this module.

As well, this module is getting simpler to use. It's been in a state of neglect for more than a year, but I'm doing my best to whip it into shape. Could you point out the issue where you'd like a maintainer's attention? I'd like to begin documenting use cases to chart out what's formally supported by this module.

@gapple:

I agree that this module's documentation is very thin. I've focused my initial contributions on fixing some longstanding or serious issues, but I hope to get some updated docs on drupal.org in the near future. It's definitely a high priority.

I would rather see twitter_field as a submodule of twitter than as a standalone module, to avoid fragmenting user choices. I'll definitely support the issue for your module, but I'd like to encourage you to consider rolling it into this module in the future. :)

Thanks, everyone!

cookiesunshinex’s picture

@gapple @michaek, I was referring to twitter_pull not twitter. Sorry for the confusion and posting in the wrong issue queue.

I've previously looked at this twitter module, and for most purposes does the trick. It's great, easy to use, but not what I'm looking for in regards to a simple CCK twitter field that pulls in a few non Oath tweets dynamically without storing anything in a database like what @gapple has provided.

gapple’s picture

@michaek
Thank you for your efforts on twitter module. I didn't mean to appear critical of any aspect of this project, I was just trying to state that twitter_pull is quite simple with no comparison to this module intended.

I do see benefits to keeping Twitter related features together in one project, as an alternative to keeping TwitterField separate due to it's lack of reliance on any other modules.
I would appreciate feedback from others on what they would prefer, and what factors are more important to them (e.g. consolidation of related modules / granularity of project downloads, linking / separation of releases). I think there are examples of both the merging and separation of other contrib modules.

iantaylor01’s picture

slight variation on #3 above... I have used twitter_pull in addition to the computed_field module to achieve something similar:
Quick instructions are:
1) Install twitter pull (http://drupal.org/project/twitter_pull) and computed field (http://drupal.org/node/126522) modules
2) Add twitter tag field to your selected content type (field_twitter_tag) - normal text field
3) Add twitter widget field to the same content type (field_twitter_widget) including the following code:
$node_field[0]['value'] = ''; // Set empty initially
// If twitter tag is entered in field_twitter_tag create widget
if (isset($node->field_twitter_tag[0]['value'])) {
if (function_exists('twitter_pull_render')) { $node_field[0]['value'] = twitter_pull_render($node->field_twitter_tag[0]['value'], 'Title', 5); }
}

4) Alter the display setting for the widget field so it is set to 'computer value' and hide tag if required
5) Create a new content...and when viewed the twitter feed should appear!

kingfisher64’s picture

Version: 6.x-3.x-dev » 7.x-5.7

Would you consider including twitterfield mod http://drupal.org/project/twitterfield by default as a disabled sub mod of this?

The use case was, I wanted to use this mod for logging in to a site via twitter. The site has profiles to which I wanted to pull down someone's feed into a profile page. The field is brilliant for this.

Is there any chance of a collaboration?

Both mods are brilliant, thanks.

Exploratus’s picture

I second #37.

It would be great if I could map a twitter field to a username, and that be enough to pull a feed. Currently I rigged a solution, where I have to add the twitter feed to the master account user page, and then I have a standard text field where I input the twitter username. Through some views magic I then create a contextual filter that looks at the text field I created and pulls that node fields tweets as per the username input.

It works, but ideally I shouldn't have to add the username twice, once at the user page level, and then again at the node level. For unauthorized accounts, it owuld be fantastic if an intelligent twitter field on a node was enough to pull an unauthenticated feed.

damienmckenna’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

There are other modules for doing this, right now we're not looking to add this functionality to the Twitter module but we'd be happy to collaborate on others on e.g. sharing variable names.