Copied to clipboard

Flag this post as spam?

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


  • Rodion Novoselov 694 posts 859 karma points
    Feb 09, 2012 @ 12:37
    Rodion Novoselov
    0

    Rebuilding the cmsContentXml table

    Hi. I've just tried to check a supposition of mine and realised that "republish entire site" doesn't refresh the cmsContentXml table. I've already had a little problem with this once when for some strange reason the content of this table went desynchronised with some document properties. Is there any mean to force refreshing of this table otherwise than complete unpublishing/publishing of documents? (what's worse is that it seems that this unpublishing/publishing should be done for every separate document).

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Feb 09, 2012 @ 12:44
    Jeroen Breuer
    1

    I don't think there's an easy solution for this. I think it's best to get all the nodes of a certain type and republish them in a script or something. Here's how you can republish all media which will also update the cmsContentXml table:

    string sql = @"
    select un.id
    from umbracoNode un
    where un.nodeObjectType = @type";
    
    //Get all the media items.
    using (IRecordsReader dr = SqlHelper.ExecuteReader(sql, SqlHelper.CreateParameter("@type", Media._objectType)))
    {
        //Loop trough all the media items.
        while (dr.Read())
        {
            //Get the id of a media item.
            int mediaId = dr.GetInt("id");
    
            //Call the save method to update the cmsContentXml and call all events.
            Media media = new Media(mediaId);
            media.Save();
            media.XmlGenerate(new XmlDocument());
        }
    }

    You can probably do the same for content.

    Jeroen

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Feb 09, 2012 @ 13:35
    Stefan Kip
    2

    From http://our.umbraco.org/wiki/reference/api-cheatsheet/publishing-and-republishing:

    Refresh the node XML

    Server.ScriptTimeout=100000;
    umbraco
    .cms.businesslogic.web.Document.RePublishAll();
    umbraco
    .library.RefreshContent();

    Note: This can also be achieved by calling http://YOURDOMAIN/Umbraco/dialogs/republish.aspx?xml=true and clicking "republish".

     

    I've used the url with ?xml=true many times, it rebuilds the entire cmsContentXml table :-)

  • Rodion Novoselov 694 posts 859 karma points
    Feb 09, 2012 @ 22:01
    Rodion Novoselov
    0

    Wow. Thanks for the info. Now that's far much clearer for me. Perhaps it would be a good idea to put a checkbox to the standard "republish entire site" dialog so that to optionally include the "RePublishAll()" call into the process of republishing - to summon this dialog manually with "?xml=true" looks a bit hackish.

  • Rodion Novoselov 694 posts 859 karma points
    Feb 10, 2012 @ 13:17
    Rodion Novoselov
    0

    I've created a very simple package that replaces the "republish.aspx" dialog with one that allows to optionally turn on refreshing the "cmsContentXml" table.

    http://our.umbraco.org/projects/backoffice-extensions/republishing-enhancement

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Feb 10, 2012 @ 13:51
    Stefan Kip
    0

    I'm not sure your package is 'wanted', because rebuilding the cmsContentXml table is kind of a hack. In normal cases you shouldn't have to rebuild the table, although I've been in situations where it was needed because something got f****d up :P

    Anyway, it's great you spent time creating the package. Rebuilding the cmsContentXml table can take up quite some time. Content editors should not be able to do something like this imo...

Please Sign in or register to post replies

Write your reply to:

Draft