help.axcms.net Axinom Logo

How to Create Categories in AxCMS.net

There are many ways to create a category in AxCMS.net - manually via GUI, WebDAV, programmatically via API or import from XML.

1. The Classic: Manually via GUI

The good old way: you click New / Category, specify the Name and optionally the other properties, click Save (or Apply) and the category is there.

Creating a Category via GUI

2. Import Categories from an XML File

Since ver 8.2.0 it is possible to import categories into AxCMS.net using XML. In order to do that, go to Edit / Categories and click on „Import categories“ button.

Import Categories

At the category import page you have to select the categories XML file from the AxCMS.net documents (you can also upload it before selecting) and use it for category import.

Import Categories - Parameters

More information about the format of the XML can be found under "Import Categories".

3. Category Creation Box

You can skip a few steps by placing a box for category creation right on the AxCMS.net Home page. First, you need to create the category box:

Category Creation Box

Once placed on the Home page, such a box allows you to create pre-configured categories very fast. Just define the necessary properties and enter the name oft he category into the Description field.

Category Creation Box in Action

You can also customize the Home page boxes programmatically.

4. WebDAV

WebDAV enables simple file exchange between a client and a web server. AxCMS.net comes with its own WebDAV server implementation. This allows editors to use any WebDAV client – the most well-known of them being Windows Explorer – to upload files into AxCMS.net. From the point of view of a WebDAV client, documents are stored in folders. AxCMS.net shows the Categories and Navigation as folders. This means that an editor can upload new documents directly into a specific category, or move documents between folders (meaning: change assigned categories).

Accessing AxCMS.net from Windows Explorer via WebDAV

Read more on configuring WebDAV with AxCMS.net.

5. Adding new categories via SQL

In most cases you will not want to create categories on the database level. There are plenty of other ways to do it, described in this article. But in some integration szenarios you still might want to add a category manually.

Please check the KB-Article How to add categories in the database.

6. Cloning

It is possible to clone navigation trees with all the content on them including categories. 

Please note that you have to create a new Site in advance before you start copying the navigation tree. Read more under Navigation / Site node.

To clone a site, go to Edit / Navigation. On the detail page, click on the Copy tree button in the Tools section on the left.

Copy Tree

A new page opens where you can define the properties for the cloning process.

Under copy from you define the source, thus the site that should be cloned, e.g. www.axinom.de.
Under copy to you select the new site where the navigation tree should be copied to, e.g. www.axinom.com.

Now you can select the assignments for categories:

- Check same documents assignment, if the same documents that are assigend, e.g. to the German website should now also be assigned to the cloned English website.

- Decide if you like to copy category relations. If this box is ticked then all relations that the navigation categories might have will be also added for the copy.

For pages you have 3 options while cloning a site:

1) you copy only the navigation structure without any pages (no pages will be copied)

2) you assign the same pages from your source site, e.g. from a German source site the pages will also be assigned to the Swiss or Austrian site (no pages are copied)

3) pages will be recreaetd. The pages will be copied from the source site and the page generation  is based on the properties of both sites' conventions.

For example, when the system gives a name to a new page, then it tries to extract the page format from the source page and applies the new format from the target site.
E.g. a page named „news_de“ (name format for this site: „*_de“) will be recreated as „news_en“ (name format for the target site: „*_en“).

When pages are copied from the source site you also have to define the relation type for the copy process.

Basically you have two possibilities:

1) circle relations

2) straight relations.

Follow the link ... and select the appropriate relation type category and click on ATTACH. Read more about relation types here.

 

 

Enter the page name format for the pages that should be copied.

Define the position where the copied navigation tree should be placed.

7. Programmatically via API

Everything you can do with AxCMS.net GUI you can also do programmatically using the API. With this code you can create new categories or navigation nodes:

AxCategoryTree categoryTree = Registry.GetCategoryTreeManager().Tree;
AxCategory category = (AxCategory)new AxCategoryAdapter().DbObject; // factory method to create a new category object
category.Name = "Test";
const int previousNodeID = 100;
categoryTree.CreateNewNode(category, previousNodeID, InsertPlace.After);

Read more on categorization in AxCMS.net.

8. API: Importing XML file programmatically

MessageCollection messages =
CMSImporter.GetCategoryImporter().Import(“categories.xml”); // put the path to your XML file

After import you should call stored procedures GenerateCategoryTree and RecalculateOrder.
Variable messages contains the results of the import, you should analyze it.

9. API: Using AxCategoryAdapter

This method is very low-level as it directly adds a record into AxCategory-table. You have to care about the correct tree structure, meaning you have to set all the redundand fields like OrderNr, update AxCategoryTree (calling stored procedures) and updating the cache. We do not recommend using it unless you need it for example for bulk insert of many categories and you understand the impact.

AxCategoryAdapter adapter = new AxCategoryAdapter();
AxCategory category = (AxCategory) adapter.DbObject;
category.Name = "Test";
… // set other Category properties
adapter.Save(category);