Code Injection
Code Injection allows you to insert custom code into different parts of a Sandvox site. For example, you might use it to add PHP directives to your site. Code Injection is a Sandvox Pro feature only.
To begin using Code Injection:
- Choose "Code Injection…" from the Site menu.
- Enter your code into the window.
There are four places code can be injected:
Before <html>
Inserted at the absolute beginning of the page, before the <html> tag. Please do not use any actual HTML code here. Note that the code inserted here will not appear in Sandvox while editing, only on the published site.
Example uses:
- PHP directives
- Setting cookies
<head> area
Inserts code in between the <head> and </head> tags.
Example uses:
- Javascript <script> tags
- <meta> tags
- Additional CSS stylesheet declarations
Within <body> tag
Inserts code inside of the <body> tag. This literally means within the tag itself, not between <body> and </body>.
Example uses:
- A Javascript "onload" tag
- Style attributes
Before </body>
Inserted right at the end of the main HTML code, just before the </body> tag. The main purpose is for Javascripts that process the preceding HTML code.
Example uses:
- Snap.com Snap Shots
- Context link advertisements like those from Kontera
- Page counters or statistics tools from places like OneStatFree.com or free-hit-counters.com
Insertion Level
Normally, you use Code Injection to affect every page in a site. However, you can also use Code Injection upon a single page or a subset of pages.
To use Code Injection at a selected level:
- Select the page in the Site Outline. (This can be a collection if you wish)
- Open the Site menu.
- Hold down the option key and choose "Code Injection at Selected Level…"
Any code entered will only affect the page you selected in the Site Outline (and any children it may have) rather than the entire site.
Inheritance
Each tab of the Code Injection window contains a checkbox labeled "Include on contained pages." This is turned on by default.
Uncheck the box and the code will only be inserted for the page indicated in the Code Injection window's title, rather than all the pages below it in the Site Outline's hierarchy.
