Jump to:

22976 Posts in 11667 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » Twitter Widget Pack Problem

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 940 Views
  • ambient
    Avatar
    Community Member
    113 Posts

    Twitter Widget Pack Problem Link to this post

    ------------UPDATE----------------

    Nevermind, I just ended up taking the twitter widget from here https://twitter.com/about/resources/widgets/widget_profile and passing variables directly into it and it works fine

    Hi all,

    I've been trying to get the Twitter feed on my website using the Twitter Widget Pack.

    I've taken the code from the TwitterProfileWidget.php and TwitterProfileWidget.ss files and transferred them to my respective Homepage files but the area for the twitter feed comes up blank.

    When I look at the source code it shows some of the variables passed properly but the defaults like height and width are still null.

    Can someone tell me am I missing something really obvious??

    Homepage.ss

    <div class="twitter_box"><!--start twitter_box-->
       <script src="http://widgets.twimg.com/j/2/widget.js" type="text/javascript"></script>
       <script type="text/javascript">new TWTR.Widget($WidgetSetupJSON).render().setUser('$User').start();</script>
    </div>
    <!--end twitter_box-->

    Source Code

    <div class="twitter_box"><!--start twitter_box-->

    <script src="http://widgets.twimg.com/j/2/widget.js" type="text/javascript"></script>

    <script type="text/javascript">new TWTR.Widget({"version":null,"type":null,"rpp":"2","interval":"0","width":"0","height":null,"theme":{"shell":{"background":"black","color":"white"},"tweets":{"background":"black","color":"white","links":"white"}},"features":{"scrollbar":true,"loop":true,"live":false,"hashtags":false,"timestamp":true,"avatars":true,"behavior":"default"}}).render().setUser('@twitter').start();</script>

    </div>
    <!--end twitter_box-->

    Homepage.php - Snippets

    public static $db = array(
       
       //Twitter
       'TwitterUser' => 'Varchar(20)',
          'TweetCount' => 'Int',
          'TweetInterval' => 'Int',
          'SizeHeight' => 'Int',
          'SizeWidth' => 'Int',
          'SizeWidthAuto' => 'Boolean',      
          'ShellBackground' => 'Varchar(7)',
          'ShellColor' => 'Varchar(7)',
          'TweetBackground' => 'Varchar(7)',
          'TweetColor' => 'Varchar(7)',
          'LinkColor' => 'Varchar(7)',
          'FeatureScrollbars' => 'Boolean',
          'FeatureLoop' => 'Boolean',
          'FeatureLive' => 'Boolean',
          'FeatureHashtags' => 'Boolean',
          'FeatureTimestamp' => 'Boolean',
          'FeatureAvatars' => 'Boolean',
          'FeatureBehavior' => "Enum('default, all', 'default')",
       //Twitter
       );
    -------------------------------------------------------------
    static $defaults = array(
          'TweetCount' => 4,
          'TweetInterval' => 10000,
          'SizeHeight' => 300,
          'SizeWidth' => 250,
          'SizeWidthAuto' => true,
          'ShellBackground' => '#333333',
          'ShellColor' => '#ffffff',
          'TweetBackground' => '#000000',
          'TweetColor' => '#ffffff',
          'LinkColor' => '#4AED05',
          'FeatureScrollbars' => false,
          'FeatureLoop' => false,
          'FeatureLive' => false,
          'FeatureHashtags' => true,
          'FeatureTimestamp' => true,
          'FeatureAvatars' => false,
          'FeatureBehavior' => 'default',
       );
    ---------------------------------------------------------------
    $fields->addFieldToTab('Root.Content.Twitter', new TextField('TwitterUser', 'Account Name'));
       $fields->addFieldToTab('Root.Content.Twitter', new DropdownField('TweetCount', 'Number of Tweets', range(1, 20)));
       $fields->addFieldToTab('Root.Content.Twitter', new NumericField('SizeHeight', 'Height (px)'));
       $fields->addFieldToTab('Root.Content.Twitter', new TextField('ShellBackground', 'UI Background Color'));
       $fields->addFieldToTab('Root.Content.Twitter', new TextField('ShellColor', 'UI Text Color'));
       $fields->addFieldToTab('Root.Content.Twitter', new TextField('TweetBackground', 'Tweet Background Color'));
       $fields->addFieldToTab('Root.Content.Twitter', new TextField('TweetColor', 'Tweet Background Color'));
       $fields->addFieldToTab('Root.Content.Twitter', new TextField('LinkColor', 'Link Color'));
       $fields->addFieldToTab('Root.Content.Twitter', new CheckboxField('FeatureScrollbars', 'Display Scrollbars'));
       $fields->addFieldToTab('Root.Content.Twitter', new CheckboxField('FeatureLoop', 'Loop Results'));
       $fields->addFieldToTab('Root.Content.Twitter', new CheckboxField('FeatureHashtags', 'Display Hashtags'));
       $fields->addFieldToTab('Root.Content.Twitter', new CheckboxField('FeatureTimestamp', 'Display Timestamp'));
       $fields->addFieldToTab('Root.Content.Twitter', new CheckboxField('FeatureAvatars', 'Display Avatars'));

    return $fields;
    }
    function User() {
          return Convert::raw2js($this->TwitterUser);
       }

       protected function WidgetSetup() {
          return array(
             'version' => $this->version,
             'type' => $this->type,
             'rpp' => $this->TweetCount,
             'interval' => $this->TweetInterval,
             'width' => ($this->SizeWidthAuto ? 'auto' : $this->SizeWidth),
             'height' => $this->Height,
             'theme' => array(
                'shell' => array(
                   'background' => $this->ShellBackground,
                   'color' => $this->ShellColor,
                ),
                'tweets' => array(
                   'background' => $this->TweetBackground,
                   'color' => $this->TweetColor,
                   'links' => $this->LinkColor,
                )
             ),
             'features' => array(
                'scrollbar' => ($this->FeatureScrollbars ? true : false),
                'loop' => ($this->FeatureLoop ? true : false),
                'live' => ($this->FeatureLive ? true : false),
                'hashtags' => ($this->FeatureHashTags ? true : false),
                'timestamp' => ($this->FeatureTimestamp ? true : false),
                'avatars' => ($this->FeatureAvatars ? true : false),
                'behavior' => $this->FeatureBehavior,
             )
          );
       }

       function WidgetSetupJSON() {
          $settings = $this->WidgetSetup();
          return Convert::raw2json($settings);
       }

    940 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.