Closed (duplicate)
Project:
Tweet Button
Version:
7.x-2.0-beta1
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
2 Mar 2013 at 00:11 UTC
Updated:
2 Sep 2013 at 01:54 UTC
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
Comment #1
jimboh commentedWell I bodged fixed it for my use case
in
function tweetbutton_tweet_get_attributes($options = array())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
i added
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.
Comment #2
berliner commentedI ran into the same problem. See #2079113: Change logic concerning tokens and field rendering for a patch.
Comment #3
berliner commentedI'll close this as a duplicate of #2079113: Change logic concerning tokens and field rendering, which also links here.