Making a document link the main document

Yehuda Lando asked on April 25, 2014 10:57

Hi,

Is there a way (in both API and the CMS Desk), to make a document link the main node?

For example, I have two tree nodes

node1 is the main node

node2 is the linked node

And I want to make node1 the linked node, and node2 the main node.

Also, related to that, how can I delete node1 and make node2 the main node (without deleting it and recreating it again).

Thanks

Recent Answers


Brenden Kehren answered on April 25, 2014 22:44

I've got a method that returns the top level alias path. Maybe this might help.

        /// <summary>
    /// Gets the top level navigation from a URL
    /// </summary>
    /// <param name="URL"></param>
    /// <returns></returns>
    public static string GetParentAlias(string URL)
    {
        // putting a dummy value in so if it cannot get a URL it will return one that doesn't exist and not display any items.
        string ReturnValue = "/unknown";
        // parse out the URL and get only the text between the first / and the second /
        int firstIndex = 0;
        string urlFirstSlashRemoved = URL.Substring(1, URL.Length - 1);
        if (urlFirstSlashRemoved.Length > 0)
        {
        // check for second level page ie: /page1/page2/
        firstIndex = urlFirstSlashRemoved.IndexOf("/");
        if (firstIndex > -1)
        {
            ReturnValue = "/" + URL.Substring(1, firstIndex);
        }
        else
        {
            // parent page
            ReturnValue = URL;
        }
        }
        return ReturnValue;
    }
0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on April 25, 2014 22:46

Regarding the deletion of a node and moving the other up, you'd have to first move the node(s) you want to make "primary" and then delete the other node. Check the APIExamples thats part of your install for code samples.

0 votesVote for this answer Mark as a Correct answer

Yehuda Lando answered on April 27, 2014 09:48

About moving the documents, if you delete the main node it will also delete all the linked nodes, so that won't work.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on April 27, 2014 21:48

As I mentioned you need to move it first, then do the delete of the original parent.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.