Hi,
I'm having an issue when inserting a page (Blog post comment) using the API.
The page is added correctly except for the fact that the DocumentNamePath property is always set with a value at the root level. The DocumentAliasPath and the rest of properties look okay.
This causes that the page appears duplicated in the content tree: in the correct location but also under the root.
I have checked that the parent node has the correct DocumentNamePath value when calling Insert (i.e. not at the root) and I have added a few columns to the query that might help but I'm missing something else.
Please my find code below:
protected readonly string[] BasePageColumns =
{
"NodeGUID", "DocumentID", "NodeID", "DocumentPageTitle", "DocumentPageDescription",
"DocumentPageKeyWords", "NodeAlias", "NodeAliasPath", "NodeSiteID", "DocumentCulture",
"BlogPostID", "DocumentNamePath", "DocumentGUID", "DocumentName", "DocumentUrlPath"
};
public BlogPost GetBlogPostNode(int blogPostId)
{
return DocumentHelper.GetDocuments<BlogPost>()
.Columns(BasePageColumns)
.OnSite(SiteContext.CurrentSiteName)
.Published()
.PublishedVersion()
.WhereEquals("BlogPostID", blogPostId)
.FirstOrDefault();
}
///
var blogPost = GetBlogPostNode(blogPostId);
var postComment = TreeNode.New<BlogPostComment>("IR.BlogPostComment");
postComment.DocumentName = "Post Comment " + (count++).ToString();
postComment.DocumentCulture = LocalizationContext.CurrentCulture.CultureCode;
postComment.BlogPostID = blogPostId;
postComment.Insert(blogPost);
And this is how the general tab of the new page looks like:
Any help would be appreciated.
Kind regards,
Gustavo