Copied to clipboard

Flag this post as spam?

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


  • Simon Hewitt 65 posts 126 karma points
    Nov 20, 2012 @ 12:22
    Simon Hewitt
    0

    Generate html via publish event

    Heres the scenario: Umbraco creates a mega menu based on its contents and some setup variables via a Razor macro, I need to store the markup that is generated by that macro in a database as it is used by a Java app which makes up the other half of the website.

    Is there any way to run the razor macro script in the actual c# code in my Document_AfterPublish event or do I have to set up a hidden page on the Umbraco site that will render just the mega menu markup and grab it from there?

  • kristian schneider 190 posts 351 karma points
    Nov 20, 2012 @ 12:47
    kristian schneider
    0

    I would throw the macro in a empty template and get the html in the Document_Afterpublish via the ?alttemplate=justthemacro

    You can then get the html with

                        var download = new WebClient().DownloadString(domain + "?alttemplate=justthemacro");
  • Simon Hewitt 65 posts 126 karma points
    Nov 20, 2012 @ 13:10
    Simon Hewitt
    0

    Many thanks,

    Works like a charm and no clutter from my users perspective.

    cheers

    Simon

Please Sign in or register to post replies

Write your reply to:

Draft