Custom Site Extensions
Custom site extensions extend a site with custom logic that applies to an extensible object.
You can create custom site extensions for most Geocortex Essentials objects. To find out if you can extend a particular type of object, edit an object of that type in Manager and check whether it has a Properties hyperlink. If the object has a Properties hyperlink, you can create a custom site extension for the object. For example, to find out if you can extend print templates, edit a print template in Manager—you will see the Properties hyperlink at the bottom of the Edit Print Template page. This means that you can extend print templates.
Example
Suppose you want to configure the visibility of the fields in a layer, as well as an alias for each field. You can do this using the following site extension:
<Layer Name="Zip Codes"> <Extensions> <Extension Assembly="Extensions" ClassName="Extensions.FieldsCollection"> <FieldsCollection> <Field Name="PO_Name" Alias="PO Name" Visible="true" /> <Field Name="ZIPCODE" Alias="Zip Code" Visible="true" /> </FieldsCollection> </Extension> </Extensions> </Layer>
Create a Custom Site Extension
The procedure below outlines the main steps to create a custom site extension.
To create a custom site extension:
-
Create and verify the core part of your site before deploying the extended portion.
-
In the development environment:
-
Create a class for each extension.
-
Implement the extension’s logic.
-
Compile the assembly or assemblies.
-
-
Deploy the assemblies and add the extension to the site
It is important to perform these steps in the order given. Site validation will fail if you deploy a site containing references to assemblies that do not exist.
-
Copy the assemblies to anywhere within the
Sites
folder.Deploying or redeploying a custom assembly causes all your sites to reload. The site is unavailable to users while Essentials loads the site.
Place assemblies that will be used by only one site in the site’s folder. Create an
Extensions
folder up one level to deploy assemblies that will be used by more than one site. -
Open the
Site.xml
file for editing. -
Add an
Extensions
element immediately after the extensible element that the property applies to. -
Add an
Extension
element beneath theExtensions
element. -
Give the
Extension
element anAssembly
attribute and assign it the name of the extension’s assembly. -
Give the
Extension
element aClassName
attribute and assign it the value of the extension's class name. -
If you are configuring more than one extension, add a
collection
element beneath theExtension
element.The collection element must be named after the class. For example, if the class name is
AssemblyName.SomeCollection
, then the collection element must be namedSomeCollection
. -
Add each element in the collection and give it a
Name
attribute, plus whatever other attributes you want it to have.If you are configuring a single element, you can skip this step—you do not need a collection element.
-
Repeat steps d - h for each extension that you created for this extensible element.
-
Repeat steps c - i for each extension class that you created.
-
Confirm your configuration by comparing it to the following example:
<Extensions> <Extension Assembly="Extensions" ClassName="Extensions.FieldsCollection"> <FieldsCollection> <Field Name="PO_Name" Alias="PO Name" Visible="true" /> <Field Name="ZIPCODE" Alias="Zip Code" Visible="true" /> </FieldsCollection> </Extension> </Extensions>
-
Save the
Site.xml
file and browse theSites
folder to confirm the extensions. -
Use the extensions in applications.
-