I've created a macro the shows a div for each childpage as part of a guestbook. When creating a new childnode programmatically using a usercontrol (node.publish and UpdateDocumentCache) the subpage is create but the macro (used in the same page) doesn't show the content. When refreshing the page using a browser refresh the content is shown as should.
What could I be forgotten. I think it's a minor error but I have no clue where to seach. Normally a server-sided node creation is a post-back so the page is refreshed ?
@inherits umbraco.MacroEngines.DynamicNodeContext @{ int pageSize; // How many items per page int page; // The page we are viewing
/* Set up parameters */
if (!int.TryParse(Parameter.PageSize, out pageSize)) { pageSize = 6; }
if (!int.TryParse(Request.QueryString["page"], out page)) { page = 1; }
/* This is your basic query to select the nodes you want */ dynamic childnodes = Model.Children.OrderBy("CreateDate desc"); int totalNodes = Model.Children.Count(); int totalPages = (int)Math.Ceiling((double)totalNodes / (double)pageSize);
page not refreshed in time?
Hi all,
I've created a macro the shows a div for each childpage as part of a guestbook. When creating a new childnode programmatically using a usercontrol (node.publish and UpdateDocumentCache) the subpage is create but the macro (used in the same page) doesn't show the content. When refreshing the page using a browser refresh the content is shown as should.
What could I be forgotten. I think it's a minor error but I have no clue where to seach. Normally a server-sided node creation is a post-back so the page is refreshed ?
Thanks for your advice.
Luuk Krijnen
Hi Luuk
You might need to set a script timeout to something like 200 ms.
See the part called "Refresh node xml" here: http://our.umbraco.org/wiki/reference/api-cheatsheet/publishing-and-republishing - in this example it's set to 1 secound, but I think 200 ms should be enough.
Hope this helps.
/Jan
Doesn't seem te work:
the macro showing the pages is like:
@inherits umbraco.MacroEngines.DynamicNodeContext
@{
int pageSize; // How many items per page
int page; // The page we are viewing
/* Set up parameters */
if (!int.TryParse(Parameter.PageSize, out pageSize))
{
pageSize = 6;
}
if (!int.TryParse(Request.QueryString["page"], out page))
{
page = 1;
}
/* This is your basic query to select the nodes you want */
dynamic childnodes = Model.Children.OrderBy("CreateDate desc");
int totalNodes = Model.Children.Count();
int totalPages = (int)Math.Ceiling((double)totalNodes / (double)pageSize);
/* Bounds checking */
if (page > totalPages)
{
page = totalPages;
}
else if (page < 1)
{
page = 1;
}
foreach (umbraco.MacroEngines.DynamicNode subpage in childnodes.Skip((page - 1) * pageSize).Take(pageSize))
{
<h3 class="nobottom inline">@subpage.Name</h3>
<span>@subpage.CreateDate.ToString("dd.MM.yy")</span>
<p>@Html.Raw(umbraco.library.ReplaceLineBreaks(subpage.GetPropertyValue("bodyText")))</p>
}
if(Parameter.DisablePaging=="0")
{
<ul class="paging">
@for (int p = 1; p < totalPages + 1; p++)
{
string selected = (p == page) ? "selected" : String.Empty;
<li class="@selected"><a href="?page=@p" title="Go to page @p of results">@p</a></li>
}
</ul>
}
}
the post-item click codebehind is like:
DocumentType CommentItem = DocumentType.GetByAlias("CommentItem");
Document newComment = Document.MakeNew(OnderwerpTextbox.Text, CommentItem, User.GetCurrent(), Node.GetCurrent().Id);
newComment.getProperty("bodyText").Value = bodyTextTextBox.Text;
newComment.getProperty("email").Value = EmailTextBox.Text;
Server.ScriptTimeout = 100000;
newComment.Publish(User.GetCurrent());
umbraco.library.UpdateDocumentCache(newComment.Id
can someone give me another hint please?
Luuk
is working on a reply...