How does one assign a custom url for the tweet button instead of defaulting to the node in question? I would like to be able to alter the url that the tweet button uses because the node in question is only accessed via a panels page - and furthermore, in the case of , for example, a facebook app, the node would be seen through an iFrame. The url on the tweet should point to the facebook app - not to the drupal node.

Is there a table that tweetbutton already uses where the data-url property can be stored - or does this require a patch for the hook_nodeapi to form-alter the edit and view ops. to lookup for a data-url?


letapjar’s picture

Ok, I implemented a workable version of this for my own purposes. Here is the process I used:

1) create a CCK field called 'tweet url' with field name field_tweet_url
2) create a CCK field called 'tweet text' with field name field_tweet_text
3) set the display of both of these fields to 'exclude' for both node and teaser - only want the input on the node edit form

4)modify tweetbutton.module to lookup these two fields during theme_tweetbutton_display()
if they are present - set them in the options array (and cache the lookup in the $node object so we only hit the db once per node)

This gives me the option of a per-node customized tweet-text and tweet-url but if the values are left blank it will fall-back on the default setting set through tweetbutton's admin settings

drawbacks to this method: 1)one should really have the cck fields created during hook_install by tweetbutton module itself 2)since we use cck for holding the data - it is possible to define tweet_text and tweet_url for node types that are not set to display a tweetbutton in tweetbutton module - this could be fixed with a form_alter that checks if the node type is activated prior to showing the node edit form
3)there are no permissions control for being able to enter tweet text and tweet url on the nodes - this could be fixed either with content_permissions - or again with a form_alter of the node edit form

If there is some interest out there in these types of customizations - please indicate so here - otherwise my modifications work for my use case (I won't have user generated content on my site where I'm using tweetbutton at the moment).

chia’s picture

Status: Active » Fixed

You should send a custom url when rendering tweetbutton

theme('tweetbutton_display', array('options' => array('url' => 'http://my/custom/url')));
letapjar’s picture

tweetbutton is rendered by it's own theme function - the point is that there was no way to explicitly store a custom url and /or tweet text per node. but thanks.

chia’s picture

You might want to checkout the d7 version there is a way to store custom text per node in d7-2.x branch, I have no plans as of now to backport that to d6, it would be really great if someone can help me on this by submitting a patch.

As of d6, you need to define a custom cck field and add that token to the tweet text on settings page.

Status: Fixed » Closed (fixed)

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