help.axcms.netAxinom Logo
Save Save Chapter Send Feedback

Working with AxSite

 

Table of contents

  1. Introduction
  2. Add and edit
  3. NavigationContext.CurrentSite
  4. AxSiteDetector
  5. Culture settings
  6. Availability and customization
  7. Extending AxSite
  8. Importing

Introduction

 

Multisite management is one of the most important features in AxCMS.net. Many companies today have the need to manage many different sites. Content needs to be published in many languages, regions and in different contexts. Tailored Microsites targeting very specific audiences are another item on their wish list. Such companies today face big challenges while managing a wealth of different sites, often operated on very different infrastructures. AxCMS.net was engineered to solve all of these problems. It enables management of multiple web site instances from one single management system.

Current article explain topic from technical (developers) prospective. If you are not familiar with AxSite, then we strongly recommend you to read this article.

Add and edit

To start with new site in the context of AxCMS.net you have to create a new child node under “Navigation” root node, which you can find under main Edit menu.

We assume that every first level child nodes are sites, which represent different domains or sub domains.


To create a new node in this list you should click menu in left operational side like seen on the picture below.


By clicking on “New Site” button you will find a standard detail page for category, with one exception – the special “Site” panel, which has extended properties listed need for site management.

To create site without any specific customization you will be asked enter only its name. We will take a closer look at other properties and their effect on site templates below.

NavigationContext.CurrentSite

Inheriting you custom project template from TemplateBase class giving developers a bunch of properties to retrieve data about request (requested navigation context, page, etc.). NavigationContext property returns you standard or custom context class which have some standard functionality to work with Navigation. In version “8.6” new property CurrentSite was introduced, which represent instance of AxSite class or custom class inherited from it.


During request of specific page NavigationContext automatically try to detect the site by matching properties of the existing sites with current request. In the end it results with proper site matched for page and based on that could be used during project custom logic implementation.

If you want detect site from the class that has no NavigationContext property defined (probably helper class), you still can detect CurrentSite. To get site object you will need to run AxSiteDetector.Find(int) and specify current ActiveID or AxSiteDetector.DetectSite() it will search AxSite by current request host or page assignments if no such host value was found. Such operations assume that you are in the context of HttpRequest.

AxSiteDetector

Is a static helper class allowing you to perform some useful operations to detect site or get some specific site values.


Most common method you might need are: DetectSite(), CheckIfThisPageBelongToSite(AxSite,page), GetSitesAssignedToClassifiable(IClassifiable).


AxSiteDetector.Sites holds statically cached dictionary of all available sites in the system.

Culture settings

In this section of AxSite properties you will find two dropdown properties – language and country. Selecting values for these properties allow controlling translation of the page or any other culture specific needs. By default, if ResourceManager is setup properly, TemplateBase class will try to translate page into language specified (learn more about country specific language here).


Translation process will use Axinom.Framework.Language assembly to perform translation of controls based on you web.config settings (see Sample solution for example).


Language and country values are represented by AxSite.Language and AxSite.Country properties. Values are two digit codes in ISO 639-1 format. One helper method is implemented for you to get suggestion of UiCulture in proper format – AxSite.GetCultureSuggestion().

Availability and customization

Specifying list of hosts for the site is fastest way to detect site during live site page request. Single host can’t have some virtual paths specified in it (bad: www.axcms.com/web/ good: www.axcms.net). You can specify virtual path in web.config if needed.


Page format is widely used during some handling operations. Also they are used in page and navigation cloning to setup proper page name to meet site specifications.


Common problem in AxCMS.net is that all the page and documents is available from same physical root directory. Specifying handler type (read here about their meaning) easily solve this problem. If site was detected, then handler automatically checks if page can be really handled under that host. Successfully validated page will be shown to request performer, in other case, depends on handling type chosen, - error, redirect or switch will happen. Special option Ignore will ignore all rules and every page will be served as correct one for request host.

Extending AxSite

It possible to add properties and their editor controls to custom AxSite instance class like it’s done for other objects like page and document. With a difference that you should extend AxSite table in database and add [OverridesAxSite] on top of your custom class that will override default AxSite.


Clue: If you want to have more control over format that is inserted by creator of the site, then you should override AxSite.Format property and perform some custom actions on it.

Importing

Together with new AxSite object it is also possible to import AxSite properties with importer classes. One of the usage is to include site properties during create application work. Follow the next code snippet to see how you do that.

<?xml version="1.0" encoding="utf-8" ?>
<Category name="ROOT" categoryId="0">
    <Category name="Navigation" categoryId="6">
        <Category name="www.live1.com">
            <Classifications>
                <Category direction="Both" path="Categories/|sample"/>
            </Classifications>
            <AxSite>
                <Property name="HostsAsString" value="www1.axsite.dev" />
                <Property name="Country" value="" />
                <Property name="Language" value="" />
                <Property name="Format" value="l1_*" />
                <Property name="NoAccessPage" value="" />
                <Property name="ServerErrorPage" value="" />
                <Property name="NotFoundPage" value="/Error.AxCMS" />
                <Property name="LoginPage" value="" />
                <Property name="NavigationHandler" value="3" />
            </AxSite>
        </Category>
    </Category>
</Category>

You can specify <AxSite> to insert properties. Note that this tag will work if you added it to children nodes of Navigation. In other places this tag will be ignored.