Copied to clipboard

Flag this post as spam?

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


  • Jes Mandrup 3 posts 23 karma points
    Mar 03, 2015 @ 14:47
    Jes Mandrup
    0

    Inserting a macro in Richtext, Umbraco 6.2.4

    Hi

    I am trying to insert a Gallery Macro in Richtext programmatically, but the maco will not render until I Save and Publish the node in the backend:

    I do something like this:

    ----------------

     private const string MediaGallery = @"<div umb_macroalias=""macro.Gallery"" umb_media=""{0}"" ismacro=""true"" onresizestart=""return false;"" umbversionid=""{2}"" umbpageid=""{1}"" title=""This is rendered content from macro"" class=""umbMacroHolder""><!-- startUmbMacro --><span style=""color: green;""><strong>Indsæt galleri</strong><br />No macro content available for WYSIWYG editing</span><!-- endUmbMacro --></div>";

    IContent contentnode = CreateNode();
    contentService.Save(contentnode);

    //Set content to Insert Gallery Macro. Using nodeid and mediafolderId

    var macro = string.Format(MediaGallery, mediaFolder.Id, contentnode.Id, contentnode.Version);
    contentnode.SetValue("content", macro);

    var status = contentService.SaveAndPublishWithStatus(contentnode);

    -----------------

    The trouble seems to be the versionId, since contentService.SaveAndPublishWithStatus will set a new versionId.

    How can my task be accomplished?

    Jes

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies