- OmCore allows you to insert custom JavaScript globally to every page of your site, to individual pages, and even to items within modules (such as product items and news articles), allowing the implementation of 3rd party scripts.
- When editing a site within the Sites module, a page within the Site tree, or an item within a module that has scripts enabled, a Scripts tab is displayed.
- There are two types of scripts which can be saved:
- Head scripts are inserted just before the closing <head> tag of your page.
- Footer scripts are inserted just before the closing </body> tag of your page.
Site scripts
- Scripts can be assigned to sites using the Sites component.
- By default scripts assigned to a site will appear on every page within your website.
Adding a script to a site
- Go to the Sites module (Website / Sites)
- Edit the site you wish to assign the script to.
- Go to the Scripts tab.
- Enter your JavaScript into either the Header script or Footer script field.
- Save your changes.
Disabling a global site script on an individual page
- Go to the Site tree module (Website / Site tree).
- In the site tree, select the page you wish to disable the script on.
- Go to the Scripts tab.
- If you wish to disable a site's head script deselect the Use global head script option or, if you wish to prevent a global footer script, deselect the Use global footer script option.
- Save your changes.
Page scripts
- Scripts can be assigned to individual pages when editing a page using the site tree.
- Scripts applied to pages will override site scripts.
Adding a script to a page
- Go to the Site tree (Website / Site tree).
- Select the page you wish to add the script to.
- Go to the Scripts tab.
- Enter your JavaScript into either the Header script or Footer script field.
- If you are assigning a Header script to the page, unselect the Use global head script option or, if you are assigning a Footer script to the page, unselect the Use global footer script option.
- Save your changes.
Module scripts
- Some modules allow scripts to be assigned to their content.
- Scripts applied to module items will override page or site scripts.
- Scripts assigned to module items will be loaded on the item's details page.
Adding a script to a module item
- In the main navigation, load the module.
- Edit the item you wish to assign the script to.
- Go to the Scripts tab.
- Enter your JavaScript into either the Header script or Footer script field.
- If you are assigning a Header script to the item, unselect the Use global head script option or, if you are assigning a Footer script to the item, unselect the Use global footer script option.
- Save your changes.
The Script tabs form fields
Use global head script
- This option is not available in the Sites module.
- Deselect this option to prevent a site's global script from loading on a particular page.
Head script
- Scripts entered here will be inserted into a document just before its closing </head> tag.
Use global footer script*
- This option is not available in the Sites module.
- Deselect this option to prevent a site's global script from loading on a particular page.
Footer script
- Scripts entered here will be inserted into a document just before its closing </body> tag.
Post is closed for comments.