I'm trying to get at the RelatedLinks data in umbraco 4.0 from C#, but the property value is empty.
I presume there is another way to get to this data, but I haven't been able to locate that information. All the information I have been able to find (including Tim's page on Nibble.be) is about how to get to the data via XSLT.
I'm secretly hoping that Tim might pipe up here and give me some clue as to how to get the list of links, although if anyone else has done this, I'd love a shove in the right direction! I've looked through the code for the relatedLinks control, but as best I can see it is fed its data directly from umbraco, rather than manually retrieving it?
[code]
Document d = new Document(1050);
XmlDocument xdoc = new XmlDocument();
xdoc.LoadXml(d.getProperty("FooterLinks").Value.ToString());
foreach(XmlNode xnode in xdoc.DocumentElement.ChildNodes) {
string title = xnode.Attributes["title"].Value;
string type = xnode.Attributes["type"].Value;
string newwindow = xnode.Attributes["newwindow"].Value;
string link = xnode.Attributes["link"].Value;
Response.Write(string.Format("Document: {0}, {1}, {2}, {3}", title, type, newwindow, link));
}
[/code]
The above solution works against the DB so at first I thought this should work.
Working with Node instead of Document:
[code]
Node node = new Node(1050);
XmlDocument xd = new XmlDocument();
xd.LoadXml(node.GetProperty("FooterLinks").Value);
foreach(XmlNode xnode in xd.DocumentElement.ChildNodes) {
string title = xnode.Attributes["title"].Value;
string type = xnode.Attributes["type"].Value;
string newwindow = xnode.Attributes["newwindow"].Value;
string link = xnode.Attributes["link"].Value;
Response.Write(string.Format("Node: {0}, {1}, {2}, {3}", title, type, newwindow, link));
}
[/code]
But I only receive: Exception Details: System.ArgumentNullException: Value cannot be null. on LoadXml.. So it seems the property is null. Haven't had the time to look at it more.. have to go eat something now :)
Getting at RelatedLinks data from C#
I'm trying to get at the RelatedLinks data in umbraco 4.0 from C#, but the property value is empty.
I presume there is another way to get to this data, but I haven't been able to locate that information. All the information I have been able to find (including Tim's page on Nibble.be) is about how to get to the data via XSLT.
I'm secretly hoping that Tim might pipe up here and give me some clue as to how to get the list of links, although if anyone else has done this, I'd love a shove in the right direction! I've looked through the code for the relatedLinks control, but as best I can see it is fed its data directly from umbraco, rather than manually retrieving it?
Does anyone have any ideas?
Thanks,
Scott
do you get anything in xslt, just need to ensure first of all that you have a value there.
Regards
Ismail
This should work:
[code]
Document d = new Document(1050);
XmlDocument xdoc = new XmlDocument();
xdoc.LoadXml(d.getProperty("FooterLinks").Value.ToString());
foreach(XmlNode xnode in xdoc.DocumentElement.ChildNodes) {
string title = xnode.Attributes["title"].Value;
string type = xnode.Attributes["type"].Value;
string newwindow = xnode.Attributes["newwindow"].Value;
string link = xnode.Attributes["link"].Value;
Response.Write(string.Format("Document: {0}, {1}, {2}, {3}", title, type, newwindow, link));
}
[/code]
The above solution works against the DB so at first I thought this should work.
Working with Node instead of Document:
[code]
Node node = new Node(1050);
XmlDocument xd = new XmlDocument();
xd.LoadXml(node.GetProperty("FooterLinks").Value);
foreach(XmlNode xnode in xd.DocumentElement.ChildNodes) {
string title = xnode.Attributes["title"].Value;
string type = xnode.Attributes["type"].Value;
string newwindow = xnode.Attributes["newwindow"].Value;
string link = xnode.Attributes["link"].Value;
Response.Write(string.Format("Node: {0}, {1}, {2}, {3}", title, type, newwindow, link));
}
[/code]
But I only receive: Exception Details: System.ArgumentNullException: Value cannot be null. on LoadXml.. So it seems the property is null. Haven't had the time to look at it more.. have to go eat something now :)
is working on a reply...