Jump to:

3444 Posts in 1030 Topics by 871 members

Template Questions

SilverStripe Forums » Template Questions » Custom HTML Code / Javascript inserted via CMS

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2
Go to End
Author Topic: 2675 Views
  • pinkp
    Community Member
    168 Posts

    Re: Custom HTML Code / Javascript inserted via CMS Link to this post

    I dont know if this got resolved, or if its written somewhere else but this is my FIX:

    Use a:

    Then in the CMS wrap your pasted code in:
    <!-- MYcode -->
    <!--End MYcode-->

    So for example my Rebel Mouse page this is my code:


    class RebelMousePage extends Page {

       public static $db = array(
       'RebelMouseCode' => 'HTMLText'

    public function getCMSFields() {

    $fields = parent::getCMSFields();
          $fields->addFieldToTab('Root.RebelMouseCode', TextAreaField::create('RebelMouseCode','Paste Your Rebel Mouse Code Here: '));
          return $fields;

    class RebelMousePage_Controller extends Page_Controller {

    And in the CMS:

    <!-- RebelMouse -->
    <script type="text/javascript" id="rebelmouse-embed-script" src="https://www.rebelmouse.com/static/js-build/embed/embed.js?site=USER&amp;height=1500&amp;flexible=1&amp;skip=about-site,show_rebelnav"></script><!--End RebelMouse-->

    In the RebelMousePage.ss


    hope this helps someone!

  • Craftnet
    Community Member
    58 Posts

    Re: Custom HTML Code / Javascript inserted via CMS Link to this post

    For the future - may be useful to someone

    Use a:
    - Text or Varchar

    In CMSfield normaly like:
    - new TextAreaField
    - newTextField

    In template

Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.