#toc { background-color:rgba(187,222,251,.6); padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; margin-bottom: 20px; width: 320px; }
On this page:• Inserting a custom HTML gadget• Inserting a code snippet• Inserting Global JavaScript• Modifying the HTML code• Coding considerationsYou can insert custom HTML or JavaScript into a custom HTML gadget or as a snippet into a content gadget on a page or page template. Inserting code as a snippet combines the code with the rest of the content gadget code, while inserting code as a custom HTML gadget keeps the code separate and makes it more easily relocated. You can also insert custom HTML as a snippet into an email, email template, or event description.You might want to insert custom code to embed audio or a video clip, or to embed a third-party widget from Google or Twitter.You can also add JavaScript code and apply it to all the pages on your site.As well, you can display the HTML for any content gadget, email, or event description, and modify it as you wish, subject to code restrictions (see below).Be careful when inserting HTML or JavaScript code since erroneous code can result in incorrect page display and problems with editing the page.Inserting a custom HTML gadgetA custom HTML gadget executes custom HTML or JavaScript code and can be easily moved to a different location on a page or page template. To insert a custom HTML gadget, follow these steps:Go to Sites pages (within the Website module) and begin editing the site page or page template.Click the Gadget list to display the list of available gadgets.Drag the custom HTML gadget from the Gadget list, and drop it on the desired location. After you have inserted the gadget, hover over the gadget and click the Settings icon. Within the gadget settings on the left, click the Edit code button.In the dialog that appears, enter your HTML or JavaScript code then click the Save button. Make sure your code does not violate any of the code restrictions (below). For instructions on using the code editor, click here.Click the Save button to save your changes to the page.Inserting a code snippetTo insert a snippet of HTML or JavaScript code in a content gadget on a Wild Apricot page or page template, or in an email, email template, blog post, or event description, follow these steps:Begin editing the site page, page template, email, email template, or event description.Click within the content gadget, email body, or event description where you want to insert your code.Click the S (Snippet) button within the toolbar towards the top of the screen. Within the code box, enter the HTML or JavaScript code. Make sure your code does not violate any of the code restrictions (below). For instructions on using the code editor, click here.Click Insert to exit the window.Click Save to save changes to the page.In some cases, the element to be displayed by the code will be represented in edit mode by a snippet icon.Once you switch to public view, the icon will be replaced by whatever your code is meant to display.Inserting global JavaScriptIf you want to add some JavaScript code to all the pages on your Wild Apricot site, and all pages you create in the future, click Settings within the Website module then click Global JavaScript (under Site settings). In the code box, enter your JavaScript. Make sure your code is surrounded by tags. For instructions on using the code editor, click here.Only full administrators can access the Global JavaScript screen.You could, for example, add JavaScript code to use Google Analytics to track traffic to your Wild Apricot site. You can add multiple scripts, one after the other.If you're including comments in your code, you need to format them differently depending on where they appear. If your comment is outside a script tag, enclose the comment within . For example:
Modifying the HTML codeIf you want to view or modify the HTML code for a content gadget, page template, email, email template, or event description, follow these steps:Begin editing the site page, page template, email, email template, or event description.Click within the content gadget, email body, or event description where you want to view or modify the code.Click the HTML icon within the toolbar. (When editing a blog or forum post, the Edit HTML option can be found within the More menu that appears on the toolbar.)  Adjust the code as required then click Save to save your changes. For instructions on using the code editor, click here.Click the Save button to save your changes.If you are frequently editing your site's HTML, you might want to use a dedicated HTML editor to make your changes then copy and paste the code back into Wild Apricot.Coding restrictionsIf you fail to close certain HTML tags, your page can become inaccessible. The tags you must close include the following: