I have several related Link with media property in my Document.
If I use the code:
@foreach (var link in @fund.FundProductInfoEN) {
everything works like expected. But I have an 1:1 Multilanguage website and the language code is stored in the session. If I change the code to get the language code from the session I have to use the .GetProperty or .GetPropertyValue method. But if I change the code to:
@foreach (var link in @fund.GetProperty("fundProductInfo" + Session["Lang"])) {
the following error occurs:
Cannot implicitly convert type 'umbraco.MacroEngines.PropertyResult' to 'System.Collections.IEnumerable'. An explicit conversion exists (are you missing a cast?)
How to loop through PropertyResult?
I have several related Link with media property in my Document.
If I use the code:
everything works like expected. But I have an 1:1 Multilanguage website and the language code is stored in the session. If I change the code to get the language code from the session I have to use the .GetProperty or .GetPropertyValue method. But if I change the code to:
the following error occurs:
Cannot implicitly convert type 'umbraco.MacroEngines.PropertyResult' to 'System.Collections.IEnumerable'. An explicit conversion exists (are you missing a cast?)
I use Version 4.7.1. Thanks for any hint.
Does this datatype return xml ? Then you should cast your property value to DynamicXml
The datatype is an ucomponent related links with media and stores these xml:
But how do I cast it to DynamicXml? do I need a using for this? If i try
@foreach (var link in @fund.GetProperty("fundProductInfo" + Session["Lang"]) as DynamicXml) {
I get the error that no Namespace or Type exists.
I think you need this
DynamicXml xml = Library.ToDynamicXml(fund.GetPropertyValue("fundProductInfo" + Session["Lang"]));
foreach(var link in xml.links) {
}
Same error: Type or Namespace 'DynamicXml' could not be found (using directive or assembly reference missing?)
you should have this directive in your macro
@using umbraco.MacroEngines;
I had to cast the loop item to dynamic to be able to access the attributs of the items.
This is my code now:
is working on a reply...