|
|
 Rank: Addict
Joined: 2/19/2007 Posts: 825 Location: Belgium
|
Hi, I Need to know how i can lookup a certain item and update it's property's.. I have an item with name : oostende Document Type: CentrumPage and i want to update these properties: xcoor ycoor I need to do this from a usercontrol Greetings, Tim
Umbraco tips and tricks: http://www.nibble.be - umbraco mvp 08/09 - certified level 1 & 2 professional
|
|
 Rank: Fanatic
Joined: 7/20/2006 Posts: 408 Location: Amsterdam
|
|
|
 Rank: Addict
Joined: 2/19/2007 Posts: 825 Location: Belgium
|
I did, but the trouble starts with the first line using umbraco.cms.businesslogic.web; ... I think this was for an older version of umbraco I am using 2.1.6
Umbraco tips and tricks: http://www.nibble.be - umbraco mvp 08/09 - certified level 1 & 2 professional
|
|
 Rank: Addict
Joined: 2/19/2007 Posts: 825 Location: Belgium
|
Fixed that, going to try to update now Greetings
Umbraco tips and tricks: http://www.nibble.be - umbraco mvp 08/09 - certified level 1 & 2 professional
|
|
 Rank: Fanatic
Joined: 7/20/2006 Posts: 408 Location: Amsterdam
|
Try to look in an existing sample (ie autoform module).
|
|
 Rank: Addict
Joined: 2/19/2007 Posts: 825 Location: Belgium
|
Managed to do it, don't know if i did it the recommended way, but it works. on page load I do this: Code:
foreach( Document tempDocument in Document.GetRootDocuments()){ if (tempDocument.HasChildren) { loopChildren(tempDocument); } }
Then i have this function So i lop through every document, and if the contenttype = "CentrumPage" and the name of my document is correct I update 2 property's and publish the document Code:
private void loopChildren(Document ParentDocument) { foreach (Document tempDocument in ParentDocument.Children) { if (tempDocument.ContentType.Text == "CentrumPage" && tempDocument.Text.ToLower() == Request["name"].ToString().ToLower()) { Label1.Text += "Centrum " + Request["name"].ToString() + " Updated";
foreach (Property tempProp in tempDocument.getProperties) { if (tempProp.PropertyType.Alias == "xcoor") { tempProp.Value = (int) Math.Round(Convert.ToDouble( Request["x"].ToString().Replace(".",",")), 0); }
if (tempProp.PropertyType.Alias == "ycoor") { tempProp.Value = (int)Math.Round(Convert.ToDouble(Request["y"].ToString().Replace(".", ",")), 0); }
} tempDocument.Publish(new umbraco.BusinessLogic.User(0) );
}
if (tempDocument.HasChildren) {
loopChildren(tempDocument);
}
}
}
Umbraco tips and tricks: http://www.nibble.be - umbraco mvp 08/09 - certified level 1 & 2 professional
|
|
 Rank: Addict
Joined: 2/19/2007 Posts: 825 Location: Belgium
|
Managed to do it, don't know if i did it the recommended way, but it works. on page load I do this: Code:
foreach( Document tempDocument in Document.GetRootDocuments()){ if (tempDocument.HasChildren) { loopChildren(tempDocument); } }
Then i have this function So i lop through every document, and if the contenttype = "CentrumPage" and the name of my document is correct I update 2 property's and publish the document Code:
private void loopChildren(Document ParentDocument) { foreach (Document tempDocument in ParentDocument.Children) { if (tempDocument.ContentType.Text == "CentrumPage" && tempDocument.Text.ToLower() == Request["name"].ToString().ToLower()) { Label1.Text += "Centrum " + Request["name"].ToString() + " Updated";
foreach (Property tempProp in tempDocument.getProperties) { if (tempProp.PropertyType.Alias == "xcoor") { tempProp.Value = (int) Math.Round(Convert.ToDouble( Request["x"].ToString().Replace(".",",")), 0); }
if (tempProp.PropertyType.Alias == "ycoor") { tempProp.Value = (int)Math.Round(Convert.ToDouble(Request["y"].ToString().Replace(".", ",")), 0); }
} tempDocument.Publish(new umbraco.BusinessLogic.User(0) );
}
if (tempDocument.HasChildren) {
loopChildren(tempDocument);
}
}
}
Umbraco tips and tricks: http://www.nibble.be - umbraco mvp 08/09 - certified level 1 & 2 professional
|
|
 Rank: Addict
Joined: 2/19/2007 Posts: 825 Location: Belgium
|
Managed to do it, don't know if i did it the recommended way, but it works. on page load I do this: Code:
foreach( Document tempDocument in Document.GetRootDocuments()){ if (tempDocument.HasChildren) { loopChildren(tempDocument); } }
Then i have this function So i lop through every document, and if the contenttype = "CentrumPage" and the name of my document is correct I update 2 property's and publish the document Code:
private void loopChildren(Document ParentDocument) { foreach (Document tempDocument in ParentDocument.Children) { if (tempDocument.ContentType.Text == "CentrumPage" && tempDocument.Text.ToLower() == Request["name"].ToString().ToLower()) { Label1.Text += "Centrum " + Request["name"].ToString() + " Updated";
foreach (Property tempProp in tempDocument.getProperties) { if (tempProp.PropertyType.Alias == "xcoor") { tempProp.Value = (int) Math.Round(Convert.ToDouble( Request["x"].ToString().Replace(".",",")), 0); }
if (tempProp.PropertyType.Alias == "ycoor") { tempProp.Value = (int)Math.Round(Convert.ToDouble(Request["y"].ToString().Replace(".", ",")), 0); }
} tempDocument.Publish(new umbraco.BusinessLogic.User(0) );
}
if (tempDocument.HasChildren) {
loopChildren(tempDocument);
}
}
}
Umbraco tips and tricks: http://www.nibble.be - umbraco mvp 08/09 - certified level 1 & 2 professional
|
|
 Rank: Addict
Joined: 2/19/2007 Posts: 825 Location: Belgium
|
Managed to do it, don't know if i did it the recommended way, but it works. on page load I do this: Code:
foreach( Document tempDocument in Document.GetRootDocuments()){ if (tempDocument.HasChildren) { loopChildren(tempDocument); } }
Umbraco tips and tricks: http://www.nibble.be - umbraco mvp 08/09 - certified level 1 & 2 professional
|
|
 Rank: Addict
Joined: 2/19/2007 Posts: 825 Location: Belgium
|
Managed to do it, don't know if i did it the recommended way, but it works. on page load I do this: Code:
foreach( Document tempDocument in Document.GetRootDocuments()){ if (tempDocument.HasChildren) { loopChildren(tempDocument); } }
Then i have this function So i lop through every document, and if the contenttype = "CentrumPage" and the name of my document is correct I update 2 property's and publish the document Code:
private void loopChildren(Document ParentDocument) { foreach (Document tempDocument in ParentDocument.Children) { if (tempDocument.ContentType.Text == "CentrumPage" && tempDocument.Text.ToLower() == Request["name"].ToString().ToLower()) { Label1.Text += "Centrum " + Request["name"].ToString() + " Updated";
foreach (Property tempProp in tempDocument.getProperties) { if (tempProp.PropertyType.Alias == "xcoor") { tempProp.Value = (int) Math.Round(Convert.ToDouble( Request["x"].ToString().Replace(".",",")), 0); }
if (tempProp.PropertyType.Alias == "ycoor") { tempProp.Value = (int)Math.Round(Convert.ToDouble(Request["y"].ToString().Replace(".", ",")), 0); }
} tempDocument.Publish(new umbraco.BusinessLogic.User(0) );
}
if (tempDocument.HasChildren) {
loopChildren(tempDocument);
}
}
}
Umbraco tips and tricks: http://www.nibble.be - umbraco mvp 08/09 - certified level 1 & 2 professional
|
|
 Rank: Addict
Joined: 2/19/2007 Posts: 825 Location: Belgium
|
test post , because I'm getting this error: System.OutOfMemoryException
Umbraco tips and tricks: http://www.nibble.be - umbraco mvp 08/09 - certified level 1 & 2 professional
|
|
 Rank: Addict
Joined: 2/19/2007 Posts: 825 Location: Belgium
|
Managed to do it, don't know if i did it the recommended way, but it works. on page load I do this: Code:
foreach( Document tempDocument in Document.GetRootDocuments()){ if (tempDocument.HasChildren) { loopChildren(tempDocument); } }
Then i have this function So i lop through every document, and if the contenttype = "CentrumPage" and the name of my document is correct I update 2 property's and publish the document Code:
private void loopChildren(Document ParentDocument) { foreach (Document tempDocument in ParentDocument.Children) { if (tempDocument.ContentType.Text == "CentrumPage" && tempDocument.Text.ToLower() == Request["name"].ToString().ToLower()) { Label1.Text += "Centrum " + Request["name"].ToString() + " Updated";
foreach (Property tempProp in tempDocument.getProperties) { if (tempProp.PropertyType.Alias == "xcoor") { tempProp.Value = (int) Math.Round(Convert.ToDouble( Request["x"].ToString().Replace(".",",")), 0); }
if (tempProp.PropertyType.Alias == "ycoor") { tempProp.Value = (int)Math.Round(Convert.ToDouble(Request["y"].ToString().Replace(".", ",")), 0); }
} tempDocument.Publish(new umbraco.BusinessLogic.User(0) );
}
if (tempDocument.HasChildren) {
loopChildren(tempDocument);
}
}
}
Umbraco tips and tricks: http://www.nibble.be - umbraco mvp 08/09 - certified level 1 & 2 professional
|
|
 Rank: Addict
Joined: 2/19/2007 Posts: 825 Location: Belgium
|
Managed to do it, don't know if i did it the recommended way, but it works. on page load I do this: Code:
foreach( Document tempDocument in Document.GetRootDocuments()){ if (tempDocument.HasChildren) { loopChildren(tempDocument); } }
Then i have this function So i lop through every document, and if the contenttype = "CentrumPage" and the name of my document is correct I update 2 property's and publish the document Code:
private void loopChildren(Document ParentDocument) { foreach (Document tempDocument in ParentDocument.Children) { if (tempDocument.ContentType.Text == "CentrumPage" && tempDocument.Text.ToLower() == Request["name"].ToString().ToLower()) { Label1.Text += "Centrum " + Request["name"].ToString() + " Updated";
foreach (Property tempProp in tempDocument.getProperties) { if (tempProp.PropertyType.Alias == "xcoor") { tempProp.Value = (int) Math.Round(Convert.ToDouble( Request["x"].ToString().Replace(".",",")), 0); }
if (tempProp.PropertyType.Alias == "ycoor") { tempProp.Value = (int)Math.Round(Convert.ToDouble(Request["y"].ToString().Replace(".", ",")), 0); }
} tempDocument.Publish(new umbraco.BusinessLogic.User(0) );
}
if (tempDocument.HasChildren) {
loopChildren(tempDocument);
}
}
}
Umbraco tips and tricks: http://www.nibble.be - umbraco mvp 08/09 - certified level 1 & 2 professional
|
|
 Rank: Addict
Joined: 2/19/2007 Posts: 825 Location: Belgium
|
Managed to do it, don't know if i did it the recommended way, but it works. on page load I do this: Code:
foreach( Document tempDocument in Document.GetRootDocuments()){ if (tempDocument.HasChildren) { loopChildren(tempDocument); } }
Then i have this function So i lop through every document, and if the contenttype = "CentrumPage" and the name of my document is correct I update 2 property's and publish the document Code:
private void loopChildren(Document ParentDocument) { foreach (Document tempDocument in ParentDocument.Children) { if (tempDocument.ContentType.Text == "CentrumPage" && tempDocument.Text.ToLower() == Request["name"].ToString().ToLower()) { Label1.Text += "Centrum " + Request["name"].ToString() + " Updated";
foreach (Property tempProp in tempDocument.getProperties) { if (tempProp.PropertyType.Alias == "xcoor") { tempProp.Value = (int) Math.Round(Convert.ToDouble( Request["x"].ToString().Replace(".",",")), 0); }
if (tempProp.PropertyType.Alias == "ycoor") { tempProp.Value = (int)Math.Round(Convert.ToDouble(Request["y"].ToString().Replace(".", ",")), 0); }
} tempDocument.Publish(new umbraco.BusinessLogic.User(0) );
}
if (tempDocument.HasChildren) {
loopChildren(tempDocument);
}
}
}
Umbraco tips and tricks: http://www.nibble.be - umbraco mvp 08/09 - certified level 1 & 2 professional
|
|
 Rank: Addict
Joined: 2/19/2007 Posts: 825 Location: Belgium
|
Managed to do it, don't know if i did it the recommended way, but it works. on page load I do this: Code:
foreach( Document tempDocument in Document.GetRootDocuments()){ if (tempDocument.HasChildren) { loopChildren(tempDocument); } }
Then i have this function So i lop through every document, and if the contenttype = "CentrumPage" and the name of my document is correct I update 2 property's and publish the document Code:
private void loopChildren(Document ParentDocument) { foreach (Document tempDocument in ParentDocument.Children) { if (tempDocument.ContentType.Text == "CentrumPage" && tempDocument.Text.ToLower() == Request["name"].ToString().ToLower()) { Label1.Text += "Centrum " + Request["name"].ToString() + " Updated";
foreach (Property tempProp in tempDocument.getProperties) { if (tempProp.PropertyType.Alias == "xcoor") { tempProp.Value = (int) Math.Round(Convert.ToDouble( Request["x"].ToString().Replace(".",",")), 0); }
if (tempProp.PropertyType.Alias == "ycoor") { tempProp.Value = (int)Math.Round(Convert.ToDouble(Request["y"].ToString().Replace(".", ",")), 0); }
} tempDocument.Publish(new umbraco.BusinessLogic.User(0) );
}
if (tempDocument.HasChildren) {
loopChildren(tempDocument);
}
}
}
Umbraco tips and tricks: http://www.nibble.be - umbraco mvp 08/09 - certified level 1 & 2 professional
|
|
 Rank: Fanatic
Joined: 7/20/2006 Posts: 408 Location: Amsterdam
|
Oh this stupid smiley bug :( Can someone please remove the smileys? I think correct display of code is more important as some smileys ;)
|
|
|
Guest |