To retrieve the values, Vorto comes with a few handy IPublishedContent extension methods (sorry, no dynamics support yet) namly HasVortoValue and GetVortoValue. These can be used as direct replacements to the built in HasValue and GetPropertyValue methods that come with Umbraco (if the value you are after isn't a Vorto value, it defaults back to the Umbraco implementation).
So, I wanted to test this, and made a default textstring property (alias: "test") on a page.
The result of the following code:
var page = Umbraco.TypedContent(1107);
var x = t.GetVortoValue("test");
is a null value.
I was expecting the value of the textbox. What am I doing wrong?
I'm also getting a similar problem, I'm running on Umbraco 7.5.3 and Vorto 1.5.3
If i run the following code
var vortoValue = Model.Content.GetVortoValue<string>("nonVortoTextstring");
var propValue = Model.Content.GetPropertyValue<string>("nonVortoTextstring");
vortoValue comes back as null while propValue gives me the textstring value
I would have assumed GetVortoValue() would default to the property value if it found the datatype doesn't use Vorto. When I use GetVortoValue() on Vorto dataypes within the same template it pulls out the content just fine, so I don't think its a setup issue.
For the time being I've created a little extension method so it falls back on the property value, not perfect but it does the trick:
public static class IPublishedContentExtensions
{
public static T GetVortoOrPropertyValue<T>(this IPublishedContent model, string propertyName)
{
T returnValue;
if (model.HasVortoValue(propertyName))
{
returnValue = model.GetVortoValue<T>(propertyName);
}
else
{
returnValue = model.GetPropertyValue<T>(propertyName);
}
return returnValue;
}
}
Default Umbraco field fallback not working?
The Vorto pages says:
So, I wanted to test this, and made a default textstring property (alias: "test") on a page. The result of the following code:
is a null value. I was expecting the value of the textbox. What am I doing wrong?
Umbraco: 7.4.3 Vorto: 1.5.2
Hey,
I'm also getting a similar problem, I'm running on Umbraco 7.5.3 and Vorto 1.5.3
If i run the following code
vortoValue comes back as null while propValue gives me the textstring value
I would have assumed GetVortoValue() would default to the property value if it found the datatype doesn't use Vorto. When I use GetVortoValue() on Vorto dataypes within the same template it pulls out the content just fine, so I don't think its a setup issue.
For the time being I've created a little extension method so it falls back on the property value, not perfect but it does the trick:
Hi Guys,
I had the same issue with the Textboxes, Nested Content and Rich Text editor.
Jack your trick did the work, Thanks for sharing it.
Cheers
Ali
is working on a reply...