Copied to clipboard

Flag this post as spam?

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


  • Sebastian Dammark 583 posts 1407 karma points
    May 22, 2013 @ 10:05
    Sebastian Dammark
    0

    Updating the content of MNTP when republishing on a new domain

    Scenario: Let's say we've build a website on testweb.whatever.dk and we used several MNTP's throughout the site.
    Now we wanna move the website to staging.whatever.dk, but a lot of links are still using the old domain when browsing the website.

    I've tried using this one: /Umbraco/dialogs/republish.aspx?xml=true and it works for most of the links.
    But it looks like that all links generated by the MNTP are not updated.

    How do I force a complete update of the entire website ?

    I'm running on a Umbraco 4.9.0

     

  • Sebastian Dammark 583 posts 1407 karma points
    May 22, 2013 @ 10:06
    Sebastian Dammark
    0

    The site has around 1000 nodes, so Save & Publish on each node is not an option :)

  • Stefan Kip 1614 posts 4131 karma points c-trib
    May 22, 2013 @ 10:46
    Stefan Kip
    0

    You could republish every node programmatically?

    public void RepublishAllNodes()
    {
        Node rootNode = new Node(-1);
        foreach (Document document in GetDescendantNodes(rootNode).Select(x => new Document(x.Id)))
        {
            SaveAndPublish(document);
        }
    }
    
    /// <summary>
    /// Returns the child nodes of this node
    /// </summary>
    /// <param name="node">The node</param>
    /// <returns>The child nodes</returns>
    public static IEnumerable<Node> GetChildNodes(INode node)
    {
        if (node == null)
            throw new ArgumentNullException("node");
    
        return node.ChildrenAsList.Cast<Node>();
    }
    
    /// <summary>
    /// Returns all descendant nodes
    /// </summary>
    /// <param name="node">The node</param>
    /// <param name="includeCurrent">Include the current node in the result</param>
    /// <returns>All descendant nodes</returns>
    public static IEnumerable<Node> GetDescendantNodes(INode node, bool includeCurrent = false)
    {
        if (node == null)
            throw new ArgumentNullException("node");
    
        if (includeCurrent)
            yield return (Node)node;
        foreach (Node child in GetChildNodes(node))
        {
            yield return child;
            foreach (Node subchild in GetDescendantNodes(child))
            {
                yield return subchild;
            }
        }
    }
    
    /// <summary>
    /// Saves and publishes a document
    /// </summary>
    /// <param name="document">The document to save and publish</param>
    public static void SaveAndPublish(Document document)
    {
        if (document != null)
        {
            document.Save();
            document.Publish(document.User);
            umbraco.library.UpdateDocumentCache(document.Id);
        }
    }
  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    May 22, 2013 @ 10:57
    Chriztian Steinmeier
    0

    Hi Sebastian,

    I'm not sure I follow completely - MNTP only stores ID's - so you're very likely to have a macro of some sorts actually generating the actual links, right?

    Obviously you haven't got any hardcoded domains in there (since Save & Publish works) but could it maybe be a caching issue?

    /Chriztian

  • Stefan Kip 1614 posts 4131 karma points c-trib
    May 22, 2013 @ 11:01
    Stefan Kip
    0

    -- Just ignore this reply ;-) --

  • Sebastian Dammark 583 posts 1407 karma points
    May 22, 2013 @ 11:04
    Sebastian Dammark
    0

    @Chriz:  All the XSLT Macros have 'Cache By Page' enabled.  But that's by default.

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    May 22, 2013 @ 11:10
    Chriztian Steinmeier
    0

    Yeah - I'm still wondering - the only thing I can see would be that the MNTP references a Widget type or similar that's using the URLPicker data-type - that one stores a URL along with the id, and if you're using the URL directly (instead of using NiceUrl() with the node-id), this would be the exact scenario you'd encounter.

    Alas, please ignore me if that's not the case :-)

    /Chriztian

  • Sebastian Dammark 583 posts 1407 karma points
    May 22, 2013 @ 11:32
    Sebastian Dammark
    100

    @Chriz:  You are the frekking man.  When you use the _MultiNodePickerHelper.xslt that is exactly what happens :)

  • kim Thomsen 59 posts 277 karma points
    May 22, 2013 @ 11:32
    kim Thomsen
    0

    Did you add a  testweb.whatever.dk  as a domain in the back office when you where testing? Thats the only reson i can think of 

  • Sebastian Dammark 583 posts 1407 karma points
    May 22, 2013 @ 11:34
    Sebastian Dammark
    1

    Noooooo ... I marked my own post as the solving answer ... not very karma like.  #h5is

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    May 22, 2013 @ 11:39
    Chriztian Steinmeier
    0

    Ha - cool!

    Use the urlpicker-helper.xslt as well, and you'll never have that problem again :-)

    (For the record: _MultiPickerHelper.xslt just delegates to your own templates for the Widgets :-)

    /Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft