Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I like to make static .html pages for server errors, but want the content to still be dynamic and the links in the footer and header to be up to date.
I wrote this code https://gist.github.com/StefanoChiodino/ad6f6860c235f4fd1d536fe53f887c2c that I'm sharing in case anyone was interested and would appreciate some feedback.
Am I right that generation is performing each time node published or unpublished?
Yes, it needs to be in order to update the header/footer navigation links! It's async so it shouldn't cause too much trouble.
A real "dirty" way to do this, would be to use some jQuery
You can even have it load in a particular DOM element of the page. So you could load in your header/footer from an umbraco driven one.
$( "#static-footer" ).load( "/umbraco-page/ footer" );
But if site will have application error, jquery code will return error too.
Ahhh ok - I getcha :-)
A good idea, but can see it slowing things down, if you're re-rendering this file on every "node save"
Maybe only re-render it, if a node of a particular type is updated which affects the header/footer. E.g. a Global Settings node
It's very complicated and convoluted to know what exactly is in the header and footer, and it's hard to maintain. The event hook should be async so there should be no problem in the backend.
Something I had to compromise that maybe you guys could help me with is I only managed to produce the .html with httpClient.GetAsync(errorPageAbsoluteUrl), while I'd like to produce the page with the template and IPublishedContent.
Stefano, you can use RenderTemplate method:
Thanks! Will that render the default template? That's perfect!
Stefano, yes, it will render the default template, but you can also specify template id if you need it.
Hope it helped you.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted