This page last changed on Oct 18, 2011 by jed.wheeler@involver.com.

twitter_feed

Displays content from one or more Twitter accounts and/or searches.

Configuration

Configuration of the Twitter Feed is very straightforward. You may add a Twitter user and/or Twitter search term to pull into the feature block:

Caching Considerations

The twitter feed may be up to 10 minutes old.

Attributes

name type required description
name string false This is a name to identify the specific feature instance that you are using in your template code. This is useful if you have multiple instances of the same feature on the same page. Note: By default, the SML will look for a nick name of "default" if you do not specify one in the tag definition.

Context Variables

name type description
twitter_feed.username string Returns the Twitter user's account name.
twitter_feed.fullname string Returns the Twitter user's full name.
twitter_feed.location string Returns the Twitter user's location.
twitter_feed.tweet_items Array of type tweet_item elements Returns a collection of tweets you can use to display on the page.
twitter_feed.user_image_url string Returns a url to the users profile picture.
twitter_feed.total_tweet_items integer Returns the size of the tweet items array.
twitter_feed.twitter_user_home string URL of the user's homepage on Twitter.
twitter_feed.search_term
string
The default search term configured for the Twitter Feed feature block.

Examples

Simple Example

Create the simplest twitter block ever:

{% twitter_feed name:"default" %}
    <h3>{{twitter_feed.username}}</h3>

    {% for story in twitter_feed.tweet_items %}
        <div class="tweet">
            <p class="message">{{ story.title | twitter_link | auto_link }}</p>
            <p class="timestamp">{{ story.published_relative_time }}</p>
        </div>
    {% endfor %}
{% endtwitter_feed %}

More Examples

Alternate HTML structure:

{% twitter_feed %}
    <ul>
        {% for tweet in twitter_feed.tweet_items limit: 4 %}
            <li>
                {{ tweet.title | twitter_link | auto_link }}
                <span class="timestamp">{{ tweet.published_relative_time }}</span>
            </li>
        {% endfor %}
    </ul>

    <p><a href="{{ twitter_feed.twitter_user_home }}">see more</a></p>
{% endtwitter_feed %}

 
Display single tweet with avatar and pagination:

{% twitter_feed name:"experts" %}
    {% paginate twitter_feed.tweets per_page:1 order:'published_at DESC, created_at DESC' %}
        <div class="tweets">
            <img src="{{twitter_feed.user_image_url}}" alt="">

            <h2>See what the experts are tweeting!</h2>

            {% for tweet in tweets %}
                <p>{{ tweet.title | twitter_link | auto_link }}</p>
            {% endfor %}
        </div><!-- /.tweets -->

        {{ pagination_links }}
    {% endpaginate %}
{% endtwitter_feed %}

FAQ

Related Topics


Document generated by Confluence on Feb 12, 2013 09:09