Existing nodes always show node title|site name for nodes that existed before installing this module.
You have to open and save each node (no changes necessary) for values set in defaults to work.
I assume this is because one of the tests for tweet-text is not finding a value for the node in the fields table (which is added when you save an existing node or create a new one).
On installation, If the content type to have the tweet button has 100s or 1000s of nodes , we don't want to have to manually edit and save all existing nodes.
Will investigate for a fix and report back.

Comments

jimboh’s picture

Well I bodged fixed it for my use case
in function tweetbutton_tweet_get_attributes($options = array())

$default_option.... 
   'tweet_text'  => variable_get('tweetbutton_tweet_text'),

holds the default value (in my case its [node:title])
but in the same function $options (which contains the values read from the node if values exist - which it won't if it is not a node added since the mod was installed) is merged with $default options by the line

$options += $default_option;

Unfortunately if $options['tweet_text'] is set eg $options['tweet_text'] = "" then whats in $default_option['tweet_text'] is lost.

I got round that by adding

$options=array_filter($options); immediately above the $options += $default_option; line. This removes array elements that are null, false or "".

Then in function theme_tweetbutton_tweet_display($variables)
immediately after the line

$attributes = tweetbutton_tweet_get_attributes($options);

i added

 if ($attributes['data-text'] == '[node:title]') $attributes['data-text'] = $variables['entity']->title;

It works for me. I wanted to get the token value from [node:title] but the method above seemed quicker (for my use case).
I think basically its not designed to work with pre-existing content. Thats ok if you are happy with it defaulting to the value which is what I think it does. In my case that exceeded the allowed number of characters so was no use.

berliner’s picture

I ran into the same problem. See #2079113: Change logic concerning tokens and field rendering for a patch.

berliner’s picture

Status: Active » Closed (duplicate)

I'll close this as a duplicate of #2079113: Change logic concerning tokens and field rendering, which also links here.