Page 1 of 1

Adding a twitter feed?

Posted: Sun Jun 23, 2013 11:26 am
by splendidbloke
Hi there,

I'm trying to embed twitter in a website for my friend (using the embed code taken from twitter), but when I paste the following code in the template in the <head> section, it doesn't work.

<__script__>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</__script>

cmsms wont let me save changes to the template and reports that there is a syntax error in the script. It works in Dreamweaver - what gives?

This link is supposed to call it or whatever.

<a class="twitter-timeline" href="https://twitter.com/MIRecordsAU" data-widget-id="348700854150377473">Tweets by @MIRecordsAU</a>

Loving CMSMS for the most part, still learning it.

thanks in advance for any help you can provide.

Re: Adding a twitter feed?

Posted: Sun Jun 23, 2013 1:20 pm
by Jo Morg
CMSMS uses Smarty engine as a template system (and a very powerful one). Smarty uses the { and } as tags enclosing chars. Depending on your version of CMSMS you can use:

Code: Select all

{literal}
<__script__>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</__script>
{/literal}
or

Code: Select all

<__script__>!function(d,s,id){# notice this: you can use a space or a newline after the { and before the }
var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){
  js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);
}
}(document,"script","twitter-wjs");</__script>
HTH

Re: Adding a twitter feed?

Posted: Mon Jun 24, 2013 7:37 am
by splendidbloke
Thanks for the reply, definitely on the right track here.

I included the {literal} tags, which got rid of the syntax error, however the twitter feed doesn't show in the page when i include the html link... just shows the text - Tweets by @MIRecordsAU

I did a bit of searching and apparently other people are having the same problem, just not sure how to fix it.