Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Peter Bersani 14 posts 34 karma points
    Dec 21, 2011 @ 20:41
    Peter Bersani
    0

    Courier 2.5 and Umbraco Relations

    I have installed Courier 2.5 on Umbraco 4.7.1 and Umbraco Relations created through the Back Office are not transferring.

    Our site is heavily dependent upon Umbraco Relations so I have built a series of Data Types in the Back Office that create Relations through the Relations API, these relations are then exposed through the front-end web pages.  When I deploy a content item using the right click method via Courier all values are transferred fine, except the Relations.

    I'm wondering if there is something I am doing wrong or have configured incorrectly.

  • Per Ploug 865 posts 3491 karma points MVP admin
    Dec 22, 2011 @ 09:06
    Per Ploug
    0

    Hi Peter

    You need to add the type of relations you wish to transfer to the /config/courier.config file, as it only transfers the ones you specificly asks it to. 

     

  • Sergio 73 posts 93 karma points
    Dec 26, 2011 @ 10:57
    Sergio
    0

    Hi Per,

    I have exactly the same problem.

    In which section of the config file do we need to add the type of the relations?

  • Peter Bersani 14 posts 34 karma points
    Dec 29, 2011 @ 18:00
    Peter Bersani
    0

    Per,

    Thanks, that worked beautifully.  One thing though is that Courier appears to transfer "added" relations, but not "removed" relations.  Is this something that is not supported?  If so, could you suggest a possible workaround?

    Thank you again

  • Peter Bersani 14 posts 34 karma points
    Dec 29, 2011 @ 18:04
    Peter Bersani
    0

    Sergio,

    At the very bottom of the /config/courier.config file there is a node <relations>, you add the child nodes within that node.  Like this.

    <relations>

    <add>myRelationType</add>

    </relations>

  • Sergio 73 posts 93 karma points
    Dec 30, 2011 @ 10:33
    Sergio
    0

    I create the relations with the API. Exactly with this code:

    Document docCopy = docCastellano.Copy(idParentSource, author, true);

    I have checked the Courier.config and I have the default configuration which it´s:

    <relations>
        <add>relateOnCopy</add>
        <!-- <add></add> -->
      </relations>

    But the related nodes are not migrated when I deploy a source node. What am I missing?

  • Peter Bersani 14 posts 34 karma points
    Jan 05, 2012 @ 15:00
    Peter Bersani
    0

    Sergio,

    I haven't user Document.Copy yet.  I've been creating relations through the Back Office using the Relations API.  I've written the following generic method to do so.  Have you checked to make sure that the Relations are indeed being created in the relations table?

             public void addRelations(int parentId, string relTypeAlias, List<int> childIds, bool overwrite)
            {
                int numRelationsAdded = 0;
                int numRelationsRemoved = 0;

                Node m_parentNode = new Node(parentId);
                string m_parentName = m_parentNode.Name;

                // Delete relations that may have been removed by this action
                foreach (Relation r in Relation.GetRelationsAsList(parentId))
                {
                    if (r.RelType.Alias == relTypeAlias)
                    {
                        int m_childId = r.Child.Id;
                        Node m_childNode = new Node(m_childId);
                        string m_childName = m_childNode.Name;

                        if (!childIds.Contains(m_childId) || overwrite)
                        {
                            r.Delete();
                            numRelationsRemoved++;
                        }
                    }
                }

                // Add relations specified by this action
                foreach (int m_childId in childIds)
                {
                    Node m_childNode = new Node(m_childId);
                    string m_childName = m_childNode.Name;

                    string m_comment = "Relating " + m_parentName + " to " + m_childName + ".";

                    if (!Relation.IsRelated(parentId, m_childId))
                    {
                        RelationType rt = RelationType.GetByAlias(relTypeAlias);
                        Relation.MakeNew(parentId, m_childId, rt, m_comment);
                        numRelationsAdded++;
                    }
                }
            }

  • Sergio 73 posts 93 karma points
    Jan 10, 2012 @ 12:38
    Sergio
    0

    Hi Peter,

    I have checked the relations table and it´s filled when you use the Document.Copy method.

    This is an example:

    Id    ParentID   childID   relType   datetime   comment

    45781    66364    66365    1    2012-01-10 12:17:46.853

     

    Checking in the UmbracoRelationType table, this is the type which it uses the method:

    1    1    C66BA18E-EAF3-4CFF-8A22-41B16D66A972    C66BA18E-EAF3-4CFF-8A22-41B16D66A972    Relate Document On Copy    relateDocumentOnCopy

    So, I have updated the Courier.config with this relation type and now it works perfectly.

    Thanks for give me the trail!!!

  • Chester Campbell 98 posts 209 karma points
    May 24, 2012 @ 21:27
    Chester Campbell
    0

    I'm having the same problem Peter had. I am running Umbraco 4.7.0 with Courier 2.6. I have updated my courier.config file with this:

    <relations>
      <add>relateDocumentOnCopy</add>
    </relations>

    I also touched the web.config to ensure that the site re-compiled. Yet, when I deploy a content document that I know has a 'relateDocumentOnCopy' relation to another document the relation is not transfered.

    What am I missing?

  • Chester Campbell 98 posts 209 karma points
    May 26, 2012 @ 00:28
    Chester Campbell
    0

    I removed all comments from courier.config and "magically" relations are now being transferred properly. Go figure.

Please Sign in or register to post replies

Write your reply to:

Draft