Portal Engine Questions on portal engine and web parts.
Version 4.x > Portal Engine > Add custom document type HELP!! View modes: 
User avatar
Member
Member
marko-softing - 2/27/2009 9:36:10 AM
   
Add custom document type HELP!!
Hi,

I added a document type for comment on news article, i added it in the admin area, and can list all comments for news. But have problem to add comment on frontend, i try the help for adding new doc type http://www.kentico.com/docs/devguide/index.html?customizing_the_administration.htm

but nothing happend, the comment is not added my code is

protected void btnAddComment_Click(object sender, EventArgs e)
{

CMS.TreeEngine.TreeProvider provider = new CMS.TreeEngine.TreeProvider(CMS.CMSHelper.CMSContext.CurrentUser);
CMS.TreeEngine.TreeNode parent = provider.SelectSingleNode(CMS.CMSHelper.CMSContext.CurrentSite.SiteName, CMS.CMSHelper.CMSContext.CurrentAliasPath.ToString(),CMS.CMSHelper.CMSContext.GetCultureClass().ToString());

CMS.TreeEngine.TreeNode node = new CMS.TreeEngine.TreeNode("cms.comment",provider);
if (parent != null)
{
node.NodeName ="fsf";
node.NodeAlias = "fsf";
node.SetValue("Name", "test");
node.SetValue("City", "test");
node.SetValue("Text", "test");
node.Insert(parent.NodeID);
}
}

User avatar
Kentico Developer
Kentico Developer
kentico_martind - 3/3/2009 6:33:51 AM
   
RE:Add custom document type HELP!!
Hi Marko,

I'm not sure where exactly you executed this code, but if you execute it on custom page in front-end there is probably no proper value in CMSContext.CurrentAliasPath property. Could you please try to debug your code and find out if CMSContext.CurrentAliasPath contains correct value and if correct object is assigned into 'parent' variable, eventually try to specify some alias path manually?

Best Regards,

Martin Dobsicek

User avatar
Member
Member
marko-softing - 3/4/2009 8:03:09 AM
   
RE:Add custom document type HELP!!
Thanks for the reply problem solved. Need a line of code before node.insert(parent.NodeID) for culture.

Like this:


node.NodeName = txtName.Text;
node.NodeAlias = txtName.Text;
node.SetValue("Name", txtName.Text);
node.SetValue("City", txtCity.Text);
node.SetValue("Text", txtText.Text);
node.SetValue("Date", DateTime.Now);
node.SetValue("DocumentCulture", parent.DocumentCulture); //throw a exeption without that line
node.Insert(parent.NodeID);

User avatar
Kentico Developer
Kentico Developer
kentico_martind - 3/11/2009 9:59:44 AM
   
RE:Add custom document type HELP!!
Yes, the 'DocumentCulture' field must be specified when creating new node.

Best Regards,

Martin Dobsicek