Adam Green
Twitter API Consultant
adam@140dev.com
781-879-2960
@140dev

Free Source Code – Twitter Display: tweet_template.txt

This template is used by get_tweet_list.php to assemble all the pieces of an individual tweet. The display formatting is done with a separate CSS file. The Twitter display plugin comes with a predefined default.css, but that can easily be replaced to create a new appearance for the tweets. All of the literal text used as part of a tweet display is stored in twitter_display_config.php.

Each tweet includes a hidden version of its tweet_id (line 2). This is used by the site.js code to determine the id of the first and last tweets in the list. The first tweet_id allows site.js to request the count of new tweets with a higher id. The last tweet_id is used to retrieve older tweets with lower ids when the View More button is clicked.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<div class="tweet">
  <div class="tweet_id hidden">[tweet_id]</div>
  <div class="tweet_image">
    <a href="http://twitter.com/[screen_name]" 
    title="[user_mention_title]">
    <img src="[profile_image_url]" width="48" height="48"></a>		
  </div>
  <div class="tweet_right">
    <div class="tweet_screen_name">
      <a href="http://twitter.com/[screen_name]" 
        title="[user_mention_title]">[screen_name]</a>
      <span class="tweet_name">[name]</span>
    </div>
    <div class="tweet_text">[tweet_text]
      <div class="tweet_date">
        <a href="http://twitter.com/[screen_name]/status/[tweet_id]" 
          title="[tweet_display_title]">[created_at]</a>
      </div>
    </div>
  </div>
</div><hr>

streaming_framework