Include files are similar to assets in that they are considered global and editing the include file updates all the pages that are using it. The main difference is that include files are hard coded into particular locations within the page templates, whereas assets can be placed in any editable region.
Include files are text files, typically with an extension of .inc, that get referenced by another page or file and included on that page or called by that file. The content can include text, script, HTML elements such as unordered lists and forms, or even variables to be called by a TCF. Include files are generally found at the site root within a folder called _resources/includes/. The obvious benefit is that rather than editing the same content multiple times to update it, it can be updated once in the include file and the files using it are updated as well.
There are any number of ways that include files can be used.
- As a file that includes the recurring text for a site
- As a file that includes a navigational element for a site
- As a header or footer file that includes a navigational element across sites for an institution
- As a file including images or text unique to a page on the site
- As left or right sidebars containing, gadgets, widgets, ads, or banners
- As a file containing a specific form to be used for a search query input
- As a file that includes a social media link bar
- With a TCF to include code snippets
Include files are generally hard coded into a particular location of the templates. For instance, headers appear at the top of the page, side navigation files appear in the same location on every page, and widgets are generally placed in a particular page location, and are not editable through each individual page’s editable regions.
It is possible to configure page properties for a page so that the include file being called can be changed on a page-by-page basis, but the location of the include stays the same. The includes are also edited once, published, and the changes appear on all pages including them.
It is also possible to use include files to make editing TCF variables easier. If multiple TCFs include the same variable sets, the variable sets can be placed in an include file and included in the TCFs. Then if the variables need to change, the include file needs to be updated.
Below are some examples of the most commonly used types of includes, and how they function. Bear in mind that the specifics of include files will most likely vary from website to website, and that the descriptions below are meant to be general descriptions of their functionality. If you are having an issue with an aspect of a specific include, it may be better to contact your institution's web help team.
A common feature in many implementations of OU Campus is a side navigation include, that provides links to navigate within the section or directory the page is located.
As a file, it is commonly named _sidenav.inc, and is stored in the section with the other page files. There is one sidenave file in each directory, and the pages within that directory pull that sidenav onto each page so all the navigations are the same. The obvious benefit of this is that if, for example, the title of a page in the directory is changed, only the include file need be edited to reflect that. The change will then automatically appear on all other pages in the directory.
When creating a new page, there will be an option to create a new navigation item along with the page, which will automatically add the appropriate link to the include file.
For more information, visit the Creating a New Page page.
When creating a new section, there will be an option to create a navigation file as well.
For more information, visit the Creating a New Section page.
Once created, a navigation include may be edited from both the file and through JustEdit on any page that includes the navigation file.
For more information, visit the Editing Includes section.
Headers and Footers
Another common use of include files is as headers and footers to make templating more efficient. Instead of duplicating the code for a common header and/or footer and putting it in each XSL file desired, the header and footer can be made in separate .inc files, and each XSL utilies an <xsl:import> command to bring the headers and footers in.
For example, in the default Gallena sandbox, the file interior.xsl (the template used to style each interior page) does not have its own code for headers and footers, but instead imports it from common.xsl.
It is also possible to save a snippet as an .inc file, instead of an .html file. This is useful more from a storage or organization perspective than anything else, as the snippet will behave the same regardless of what format it is saved in.
For more information on snippets, visit the Snippets page.