We have setup a media type called "Banner" this has the same properties as a media image, except it has an additional tab with containts a field ("imageLink") to hold a URL Link value which is a textfield. On our document type we have an Ultimate picker field which is called "bannerItems" where a user can select multiple items from the Banners folder in the media section.
I then wrote some razor to output the selected banners onto the relevant page. The razor code is as follows:
Quite a simple script which checks to see if the imageLink field has a value stored in it and then renders the relevent banner with or without a link. But I can't seem to get the .HasValue to work it always renders the banners without the link. And when I output the value of imageLink to the page like this:
<p>@banner.imageLink</p>
I get the following results:
For banners that have text stored in the field I get the value as expected (e.g. http://www.google.com), but for banners that have no value against imageLink I get the following outputted to the screen:
Where the link isn't rendered if the imageLink field is left blank. But each check / if statement doesn't seem to work or it thinks it contains "umbraco.MacroEngines.DynamicXml"
.HasValue doesn't seem to work
Hi Guys!
We have setup a media type called "Banner" this has the same properties as a media image, except it has an additional tab with containts a field ("imageLink") to hold a URL Link value which is a textfield. On our document type we have an Ultimate picker field which is called "bannerItems" where a user can select multiple items from the Banners folder in the media section.
I then wrote some razor to output the selected banners onto the relevant page. The razor code is as follows:
Quite a simple script which checks to see if the imageLink field has a value stored in it and then renders the relevent banner with or without a link. But I can't seem to get the .HasValue to work it always renders the banners without the link. And when I output the value of imageLink to the page like this:
I get the following results:
For banners that have text stored in the field I get the value as expected (e.g. http://www.google.com), but for banners that have no value against imageLink I get the following outputted to the screen:
umbraco.MacroEngines.DynamicXml
Any help on this would be greatly appreciated.
Cheers,
Hefin
Hii Hefin
try this :
Thanks for your reply, unfortunatley I still get the same behaviour. After adding your code the result I get is as follows:
Hi Hefin,
You could check if the upload file is empty
//fuji
That gives the same result as above.
Where as the result should be:
Where the link isn't rendered if the imageLink field is left blank. But each check / if statement doesn't seem to work or it thinks it contains "umbraco.MacroEngines.DynamicXml"
Try this :
Something like:
var banners = Model.bannerItems;
if(banners.Count() > 0)
{
}
I've had similar issues when I've added a propertry to a doctype when there are existing pages of that doctype.
is working on a reply...