15 January 2013

Twitter on Desire2Learn

It's easy to post a Twitter widget inside your Desire2Learn course offering. You can post your own tweets, tweets from other people, or define a search term. Twitter has a code generator on its site (https://twitter.com/settings/widgets) but that requires listing a domain where the timeline will be embedded and that apparently does not work with D2L. However, you can use the old code.

Copy and paste the following code into the HTML view of your widget content. Below the code are a couple of important notes:

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

<script type="text/javascript">// <![CDATA[
new TWTR.Widget({
  version: 2,
  type: 'profile',
  rpp: 6,
  interval: 30000,
  width: 'auto',
  height: 300,
  theme: {
    shell: {
      background: '#f57e24',
      color: '#143c8d'
    },
    tweets: {
      background: '#143c8d',
      color: '#ffffff',
      links: '#F7A96E'
    }
  },
  features: {
    scrollbar: false,
    loop: false,
    live: true,
    behavior: 'all'
  }
}).render().setUser('ProfessorBeyrer').start();
// ]]></script>


Notes:
  • There is one variable that you will likely change: the Twitter user whose timeline appears in the widget. This is the setUser variable toward the end of the code. The code includes the sample user "ProfessorBeyrer."
  • This code is for a widget with tweets from a single user. You can also use it for designated search terms. To do that, change the following:
    • type: 'profile' change to type: 'search'
    • setUser change to setSearch
    • Type the search terms you want to display in the widget to replace the sample "ProfessorBeyrer." Your students will not be able to change the search terms, and you will not be able to control what appears in the widget.
  • Other variables that you might want to change are the color codes for backgroundcolor, and links.
  • Within D2L, consider changing the widget's settings (click the Customize tab while editing the widget) to avoid competing borders and title bars, as the Twitter widget includes these already.

3 comments:

JessicaH said...

Thanks so much for this! I'm just starting to use Twitter for my online classes to try and have some more spontaneous interactions with the students.

John Martin said...

Thanks! What does one need to edit to create hashtag search?

Plamen Miltenoff said...

excellent, thanks!..