Search code examples
htmldjangodjango-cmsdjangocms-text-ckeditor

Django CMS : How to place a button inside CMS preserving the link


I am using text plugin ( ck-editor ):

Below is my source:

<button onclick="location.href='http://www.example.com'" type="button">www.example.com</button>

After saving the text plugin, I could notice that the source under text plugin has changed as below:

 <button type="button">www.example.com</button>

Am I using a wrong plugin? How to handle this case by preserving the link of the button.


Solution

  • The ckeditor sanitises content but you can specify additional tags & attributes as you can see here which shows you can provide these settings;

    TEXT_ADDITIONAL_TAGS = ('iframe',)
    TEXT_ADDITIONAL_ATTRIBUTES = ('scrolling', 'allowfullscreen', 'frameborder')
    

    So you could add set TEXT_ADDITIONAL_ATTRIBUTES = ('onclick', )