Adding a twitter feed?

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
splendidbloke
New Member
New Member
Posts: 8
Joined: Thu May 16, 2013 8:37 am

Adding a twitter feed?

Post 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.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1974
Joined: Mon Jan 29, 2007 4:47 pm

Re: Adding a twitter feed?

Post 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
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
splendidbloke
New Member
New Member
Posts: 8
Joined: Thu May 16, 2013 8:37 am

Re: Adding a twitter feed?

Post 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.
Post Reply

Return to “Modules/Add-Ons”