help.axcms.netAxinom Logo
Save Save Chapter Send Feedback

Import of pages

 

Here the existing classes are described to give you an impression what is done and what can be customized. At the bottom you will find an description about how to create your custom importer.

BaseImporter

User
User who is importing. If not passed in constructor = AxContext.CurrentUser.

CategoryTree
Current category tree. If not passed in constructor = Registry.GetCategoryTreeManager().Tree.

SpecialProperties
A list containing the names of properties that should be handled in an individual way. You can then override the function ConvertSpecialProperties to handle them the way you like.

Import
In this function the import is handled. It is empty in BaseImporter.

ReadAndSetCategories
This function reads out the "Categories/Category" xml nodes from the element node, e.g. Page, Document. If the Categories tag is defined but has no children, the element gets declassified.
If no Categories tag is present, nothing is done. If there are assignments defined, the element gets declassified first and then the assignments are imported from element node.
The value of the category, the element should be assigned to, should be a path, e.g. "Navigation/www.axcms.net/TOP".

ReadAndSetProperties
This function reads out the "Properties/Property" xml nodes from the element e.g. Page, Document...
If the property is an AxEmbeddedObject and the node contains a subName attribute, the properties of the embedded object are set too. If the property itself has an attribute [ContentXmlImmutable]
the value from xml file is ignored. If the name of the property is contained in SpecialProperties list, the function ConvertSpecialProperties is called for the property.

ConvertSpecialProperties
Override this function if you have special properties defined in SpecialProperties list. In this function you can define what value should be set to the object’s property.

Relate
This function reads out the "Relations/Relation" xml nodes from the element e.g. Page, Document...
If the Relations tag is defined but has no children, all relations of the element get deleted.
If no Relations tag is present, nothing is done.
Otherwise the element gets de-related in given relation type and after that the given relations are added again.

FindRelationID
This function reads relation type. It first checks if the given key is an int and returns it.
Otherwise the given key can be e.g. "StraightRelationTypes/Thumbnail" - so the id of relation node is read out from category tree.
You can override it if you need special behaviour here.

FindElementID
This function reads element id of element in relation node. It first checks if the given key is an int and returns it.
Otherwise the key should be:
Pages - url, e.g. /Home.AxCMS
Document - name of document
MSUser/LSUser - username
Category - path in category tree

 

PageImporter

CmsSite
Current CmsSite. If not passed in constructor = Registry.GetCmsSite().

SpecialParameters
A list containing the names of parameters of dynamic controls that should be handled in an individual way. You can then override the function ConvertSpecialParameters to handle them the way you like.
Default the list contains "CategoryID".

Import
Pass absolute file path to xml file and then the pages declared in xml file get imported in system. If page already exists the values get updated. If you pass a string, the xml get loaded.

ProcessPage
Loads or creates a page for given node, checks user rights, sets properties, sets assignments to categories and relates the page.

GetPage
Loads or create page. Takes care of if template has switched or name has changed.

ProcessPlaceholder
Adds content to the page/newsletter/mailtemplate.

GetParameters
Reads the Parameters/Parameter of element node. If one paramater name is included in SpecialParameters list, the function ConvertSpecialParameters is called for this parameter.

ConvertSpecialParameters
Override this function to process your special parameters. Default the parameter "CategoryID" is processed.

 

Custom Importer

To write your custom page importer, you can simple create a new class and inherit either from PageImporter. Make sure your custom class implements interface IImporter and give it the attribute OverridesPageImporter.

The page importing functionality will then use your class. If you need to access the current importer, you can do it like that:

IImporter myImporter = CMSImporter.GetPageImporter();

The property PageImporterClass will return Type of current importer. Please provide an empty constructor in your custom importer class.

In your create app you can instantiate then your custom importer class to import the objects.