How To Add Iframe Tag In Django CMS Placeholder

If you ever tried to add iframe tag in  djangocms placeholder , you  will notice that it will not work  as you  expect. DjangoCMS will convert iframe  tag  in other format and it will be shown as text


Add Iframe Tag In Django CM

ifraem django cms


This tutorial explains how to  trick djangoCMS with jQuery and add iframe in placeholder.  In your base.html , before </body> tag add


             var pathname = window.location.pathname;
               var facebook='<iframe src="//'+pathname+'%2F&amp;width&amp;layout=standard&amp;action=like&amp;show_faces=true&amp;share=true&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; height:80px;" allowTransparency="true"></iframe>'
             $( "#facebook" ).html(facebook);



$( "#facebook" ).html(facebook); will add variable called facebook in div tag with id = "facebook" ,

variable pathname contain current URL, for example if you open , in variable pathname will be stored how-add-iframe-tag-django-cms-placeholder/

So now got to Source mode and add div with id "facebook", and you'll set upp facebook like box

iframe django

and you'll get facebook like box as shown below



You can use the same technique to add any iframe tag.


               var variable1='<iframe src="URL1"></iframe>';
             $( "#iframe1" ).html(variable1);

            var variable2='<iframe src="URL1"></iframe>';
             $( "#iframe2" ).html(variable2);

            // can add iframe tag as many you want



Then in placeholder add div tag with id-s which you specify in jQuery , for example above ids are  "iframe1" , "iframe2" Dec. 22, 2014, 7:04 a.m.