AI agents: the content index is at /llms.txt. Every page is also available as Markdown — send the request header Accept: text/markdown, or append .md to the page URL.
Xperience Docs

Cookie consent

We use necessary cookies (opens in a new tab) to run our website and improve your experience while browsing. Additional cookies are only used with your consent. You may revoke your consent on the Cookies Policy (opens in a new tab) page or in your browser at any time.

Configure (opens in a new tab)
  • Documentation
    InstallationUsing the Xperience interfaceDeveloping websitesConfiguring XperienceManaging usersSecuring websitesDeploying websitesManaging website contentMultilingual websitesMacro expressionsExternal utilitiesIntegrating 3rd party systemsCustom developmentE-commerce featuresOn-line marketing featuresRelease notes - Xperience 13Xperience terminology glossary
  • Tutorial
    Using the Xperience interfaceDeveloper tutorialBusiness tutorialResource hub for marketers
  • API Examples
    ConfigurationContent managementDevelopmentE-commerceOn-line marketingSocial media
  1. Home
  2. Content management
  3. Page relationships

Page relationships


Was this page helpful?

Send us feedback Go back to top
  • Community Questions & Answers (opens in a new tab)
  • Contact support (opens in a new tab)

List of examples:

  • Relationship names (types)
    • Creating a relationship name
    • Updating a relationship name
    • Updating multiple relationship names
    • Assigning a relationship name to a site
    • Removing a relationship name from a site
    • Deleting a relationship name
  • Page relationships
    • Creating and removing a relationship between pages

Relationship names (types)

Creating a relationship name

C#
// Creates a new relationship name object
RelationshipNameInfo newName = new RelationshipNameInfo();

// Sets the relationship name properties
newName.RelationshipDisplayName = "New relationship";
newName.RelationshipName = "NewRelationship";

// Saves the relationship name to the database
RelationshipNameInfo.Provider.Set(newName);
> Back to list of examples

Updating a relationship name

C#
// Gets the relationship name
RelationshipNameInfo updateName = RelationshipNameInfo.Provider.Get("NewRelationship");

if (updateName != null)
{
    // Updates the relationship name properties
    updateName.RelationshipDisplayName = updateName.RelationshipDisplayName.ToLower();

    // Saves the updated relationship name to the database
    RelationshipNameInfo.Provider.Set(updateName);
}
> Back to list of examples

Updating multiple relationship names

C#
// Gets all relationship names whose code name starts with 'New'
var relationshipNames = RelationshipNameInfo.Provider.Get().WhereStartsWith("RelationshipName", "New");

// Loops through individual relationship names
foreach (RelationshipNameInfo name in relationshipNames)
{
    // Updates the relationship name properties
    name.RelationshipDisplayName = name.RelationshipDisplayName.ToUpper();

    // Saves the updated relationship name to the database
    RelationshipNameInfo.Provider.Set(name);
}
> Back to list of examples

Assigning a relationship name to a site

C#
// Gets the relationship name
RelationshipNameInfo relationshipName = RelationshipNameInfo.Provider.Get("NewRelationship");

if (relationshipName != null)
{
    // Allows the relationship name to be used on the current site
    RelationshipNameSiteInfo.Provider.Add(relationshipName.RelationshipNameId, SiteContext.CurrentSiteID);
}
> Back to list of examples

Removing a relationship name from a site

C#
// Gets the relationship name
RelationshipNameInfo relationshipName = RelationshipNameInfo.Provider.Get("NewRelationship");

if (relationshipName != null)
{
    // Gets the relationship between the relationship name and the current site
    RelationshipNameSiteInfo nameSite =
        RelationshipNameSiteInfo.Provider.Get(relationshipName.RelationshipNameId, SiteContext.CurrentSiteID);

    // Removes the relationship name from the site
    RelationshipNameSiteInfo.Provider.Delete(nameSite);
}
> Back to list of examples

Deleting a relationship name

C#
// Gets the relationship name
RelationshipNameInfo deleteName = RelationshipNameInfo.Provider.Get("NewRelationship");

if (deleteName != null)
{
    // Deletes the relationship name
    RelationshipNameInfo.Provider.Delete(deleteName);
}
> Back to list of examples

Page relationships

Creating and removing a relationship between pages

C#
// Gets the relationship name
RelationshipNameInfo relationshipName = RelationshipNameInfo.Provider.Get("NewRelationship");

if (relationshipName != null)
{
    // Gets the pages that will be connected through the relationship
    TreeNode firstPage = new DocumentQuery<TreeNode>()
                             .Path("/FirstPage", PathTypeEnum.Single)
                             .OnSite("MySite")
                             .TopN(1)
                             .FirstOrDefault();

    TreeNode secondPage = new DocumentQuery<TreeNode>()
                              .Path("/SecondPage", PathTypeEnum.Single)
                              .OnSite("MySite")
                              .TopN(1)
                              .FirstOrDefault();

    // Creates the relationship between the pages
    RelationshipInfo.Provider.Add(firstPage.NodeID, secondPage.NodeID, relationshipName.RelationshipNameId);

    // Removes the relationship between the pages
    RelationshipInfo.Provider.Remove(firstPage.NodeID, secondPage.NodeID, relationshipName.RelationshipNameId);
}
> Back to list of examples