ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Quick and simple Twitter display

May 10, 2009 11:30am

Subscribe [10]
  • #1 / May 10, 2009 11:30am

    I’ve avoided the word integration because it really isn’t, but anyway.

    Recently I’ve been messing about with Twitter (who hasn’t) and I’ve come up with a fairly simple way of displaying my Twitter feed, but without:

    1. Making all feeds one giant link back to Twitter
    2. The URLs rendering as plain text

    For this, you will need:

    1. The Magpie RSS plugin
    2. The Auto Linker Plugin
    3. The Replace Plugin

    You will also need your Twitter feed’s RSS location (mine’s http://twitter.com/statuses/user_timeline/34575329.rss), and your Twitter username, which obviously you know!

    Install all 3 plugins, create an empty template and enter the following lines of code

    {exp:replace find="username:SPACE" replace=""}
    {exp:auto_linker}
    {exp:magpie url="http://twitter.com/statuses/user_timeline/34575329.rss" limit="4" refresh="1"}
    <ul>
    {items}
    <li>{title}</li>
    {/items}
    </ul>
    {/exp:magpie} 
    {/exp:auto_linker}
    {/exp:replace}

    Replace username with your Twitter username and make sure the colon and SPACE follow, as those will also remove the colon and blank space after your username. Also remember to use your own Twitter feed location and the refresh rate is your own preference! 1 isn’t actually the best idea…

    Now, save your template and click to view it… hey presto, you should see your feed printed with any URLs rendered correctly.

    Example available at http://www.dasgrafik.co.uk/test - it’s where I muck about with code so don’t expect anything too wild!

    Now, if anyone has any improvement or suggestions - just say! I have to go out now as the shops close in 20 minutes, but I’ll check this when I get back in just in case I’ve written something wrong!

    Enjoy.

  • #2 / May 10, 2009 3:32pm

    Arun S.

    792 posts

    Good work.  I just wanted to point out that Lodewijk (developer of Replace plugin) recommends omitting the replace= parameter instead of supplying an empty thread when replacing a string with nothing.  I don’t think including it will cause harm, though.

  • #3 / May 10, 2009 4:09pm

    Justin Long

    196 posts

    Sweet deal, but what is the benefit of using this over something like the Twitter Timeline Plugin?

  • #4 / May 10, 2009 4:22pm

    @Arun S. Yeah, I omit the replace parameter on my own site. It was more for the sake of demonstration.

    @Justin Long. No idea, really - just a different way of doing things. I already had the plugins installed, so it’s an argument against installing yet another plugin to achieve something that could already be achieved with a little lateral thinking.

    Plus I don’t need to put my Twitter details into the template, which is something I’m happy about.

  • #5 / May 18, 2009 6:38pm

    Hoosteeno

    109 posts

    This works great, thanks for posting.

  • #6 / May 18, 2009 6:47pm

    This works great, thanks for posting.

    Glad to help.

    It also works with the RSS feeds for Twitter searches, which helps with a client’s conference site - they can publish the official tag for the conference, and display all public Twitter feeds which use that tag (stripping out the tag, of course).

  • #7 / Jun 11, 2009 3:58pm

    debbieT

    21 posts

    Thank you sooo much for this! A lot better than the Twitter Timeline plugin, and better than just inserting the Twitter RSS.

    I love this so much more! Thanks!

  • #8 / Jun 12, 2009 3:16pm

    serafico

    58 posts

    Works fine. Thanks. I see, the Magpie plugin can be used in many situations.

  • #9 / Jun 24, 2009 9:37pm

    craiguffman

    100 posts

    Thanks for this, dasgrafik.  It works wonderfully.

    Can you explain to me how to strip out the hashtags?  I using RSS feeds for hashtags but I want to strip them out.

  • #10 / Jul 01, 2009 6:09pm

    bluesonora

    90 posts

    schweet! i added the date - {pubdate} works, btw.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases