Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Im slowly going crazy... Simple as it is, cant get it to work :|
myLink returns "1061" but this doesn't work...
@{ var myLink = @fieldset.GetValue("slideLink"); } <a href="@umbraco.library.NiceUrl(myLink)">Click</a>
This works (but is not very usable :) :
<a href="@umbraco.library.NiceUrl(1061)">Click</a>
What type is fieldset? Have you tried something like the following, assuming your fieldset is of type IPublishedContent?
@{ var id = fieldset.GetPropertyValue<int>("slideLink"); var url = Umbraco.NiceUrl(id); }
Archetype?
@{ var myLink = fieldset.GetValue<int>("slideLink"); } <a href="@Umbraco.NiceUrl(myLink)">Click</a>
Yup tried that, you cant <int>, it returns an errror.
.fieldset is an archetype
How about:
@umbraco.library.NiceUrl(int.Parse(myLink))
You had a @ in the variable before, did you try without that?
Thanks kip, that did it.
Yeah Jeavon tried it noth with and without
var myLink = fieldset.GetValue<int>("slideLink");
and
var myLink = @fieldset.GetValue<int>("slideLink");
Ok, I will investigate further. In the meantime to avoid obsolete umbraco.library this should work:
<a href="@Umbraco.NiceUrl(int.Parse(myLink))">Click</a>
Yup, thanks
I've just tried this and it worked fine:
@foreach (var fieldset in Model.Content.GetPropertyValue<ArchetypeModel>("myarchetype")) { if (fieldset.HasValue("slideLink")) { var myLink = fieldset.GetValue<int>("slideLink"); <a href="@Umbraco.NiceUrl(myLink)">Click</a> } }
So, I'm going to guess that you had a slideLink without a value. Adding the fieldset.HasValue deals with this to prevent the exception.
fieldset.HasValue
Well... I had to change the for each, because i wanted to check if a node was first... So i have:
@{ var slider = Model.Content.GetPropertyValue<ArchetypeModel>("slider"); foreach (var fieldset in slider) { if (fieldset.Equals(slider.First())) { <div class="item active"> <div class="carousel-caption"> @{ var myLink = @fieldset.GetValue("slideLink"); } <a href="@Umbraco.NiceUrl(int.Parse(myLink))"><p>@Html.Raw(myStrippedText)</p></a> </div> </div> } }}
and adding the <int> here causes an error...
How about like this:
@{ var slider = Model.Content.GetPropertyValue<ArchetypeModel>("slider"); foreach (var fieldset in slider) { if (fieldset.Equals(slider.First())) { <div class="item active"> <div class="carousel-caption"> @if (fieldset.HasValue("slideLink")) { var myLink = fieldset.GetValue<int>("slideLink"); <a href="@Umbraco.NiceUrl(myLink)"><p>something</p></a> } </div> </div> } } }
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
get url from nodeid
Im slowly going crazy... Simple as it is, cant get it to work :|
myLink returns "1061" but this doesn't work...
This works (but is not very usable :) :
What type is fieldset? Have you tried something like the following, assuming your fieldset is of type IPublishedContent?
Archetype?
Yup tried that, you cant <int>, it returns an errror.
.fieldset is an archetype
How about:
You had a @ in the variable before, did you try without that?
Thanks kip, that did it.
Yeah Jeavon tried it noth with and without
and
Ok, I will investigate further. In the meantime to avoid obsolete umbraco.library this should work:
Yup, thanks
I've just tried this and it worked fine:
So, I'm going to guess that you had a slideLink without a value. Adding the
fieldset.HasValue
deals with this to prevent the exception.Well... I had to change the for each, because i wanted to check if a node was first... So i have:
and adding the <int> here causes an error...
How about like this:
is working on a reply...