Calling RenderTemplate from surface controller view
I need to retrieve the contents of every page on the small site I'm working on and append it to the home page. I have this almost working however am finding that the forms do not work.
This is how I get the Html for each page to append to the home page.
I call a surface controller from ajax like so
$(function () {
$.get("/umbraco/surface/homepagesurface/renderfullsite/", function (data) {
$("#all-pg-code").append(data);
});
});
The surface controller then returns a partial view
public PartialViewResult RenderFullSite()
{
return PartialView("_RenderFullSite");
}
Which calls render template on each of the pages of the site, concatenates the HTML and outputs it.
StringBuilder sb = new StringBuilder();
foreach (var item in childNodes)
{
HtmlDocument htmlDoc = new HtmlDocument();
htmlDoc.LoadHtml(Umbraco.RenderTemplate(item.Id, item.TemplateId).ToHtmlString());
HtmlNode node = htmlDoc.DocumentNode.SelectSingleNode("//div[@class=\"content-container\"]");
if (node != null)
{
// do some stuff to remove some html we don't need
sb.Append(node.OuterHtml);
}
}
@Html.Raw(sb.ToString());
Several of the pages have a short contact form on it however when this is submitted it is being submitted to the surface controller URL (/umbraco/surface/homepagesurface/renderfullsite/) and not the home page URL.
Can anyone advise me how I can get the forms working.
Calling RenderTemplate from surface controller view
I need to retrieve the contents of every page on the small site I'm working on and append it to the home page. I have this almost working however am finding that the forms do not work.
This is how I get the Html for each page to append to the home page.
I call a surface controller from ajax like so
The surface controller then returns a partial view
Which calls render template on each of the pages of the site, concatenates the HTML and outputs it.
StringBuilder sb = new StringBuilder(); foreach (var item in childNodes) { HtmlDocument htmlDoc = new HtmlDocument(); htmlDoc.LoadHtml(Umbraco.RenderTemplate(item.Id, item.TemplateId).ToHtmlString()); HtmlNode node = htmlDoc.DocumentNode.SelectSingleNode("//div[@class=\"content-container\"]"); if (node != null) { // do some stuff to remove some html we don't need sb.Append(node.OuterHtml); } } @Html.Raw(sb.ToString());
Several of the pages have a short contact form on it however when this is submitted it is being submitted to the surface controller URL (/umbraco/surface/homepagesurface/renderfullsite/) and not the home page URL.
Can anyone advise me how I can get the forms working.
is working on a reply...