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
To start of. I'm new to umbraco.
I have the following. When it takes no tag in the URL. So it takes CurrentPage.Children the code works. But when I am loading the TagQuery I get an error saying that overviewQuote is not defined.
@{ Layout = "Master.cshtml"; string tag = Request.QueryString["tag"]; var stories = CurrentPage.Children; if(!tag.IsNullOrWhiteSpace()){ stories = Umbraco.TagQuery.GetContentByTag(tag, "stories"); } } <a href="@story.Url"> <h2>@story.overviewQuote</h2> <img src="@Umbraco.Media(story.overviewImage).Url" alt="@Umbraco.Media(story.overviewImage).Name"> </a>
When I do this it works in both scenarios, but the image does not get loaded. The code says "undefined".
@{ Layout = "Master.cshtml"; string tag = Request.QueryString["tag"]; var stories = CurrentPage.Children; if(!tag.IsNullOrWhiteSpace()){ stories = Umbraco.TagQuery.GetContentByTag(tag, "stories"); } } <a href="@story.Url"> <h2>@Umbraco.Field(story, "overviewQuote")</h2> <img src="@Umbraco.Media(@Umbraco.Field(story, "overviewImage")).Url" alt="@Umbraco.Media(@Umbraco.Field(story, "overviewImage")).Name"> </a>
Can someone please tell me what the best practice is to do this?
thanks
Personally, i would avoid using the Dynamic model and instead use Model.Content instead of CurrentPage.
Then get the property data via the GetPropertyValue method
story.GetPropertyValue<string>("overviewQuote")
That's just perfect. Now it all works. Thank you very much !
Just for future reference. What's the difference between the two. And when do you use which one?
No worries, glad it worked out for you.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Umbraco.TagQuery.GetContentByTag
To start of. I'm new to umbraco.
I have the following. When it takes no tag in the URL. So it takes CurrentPage.Children the code works. But when I am loading the TagQuery I get an error saying that overviewQuote is not defined.
When I do this it works in both scenarios, but the image does not get loaded. The code says "undefined".
Can someone please tell me what the best practice is to do this?
thanks
Personally, i would avoid using the Dynamic model and instead use Model.Content instead of CurrentPage.
Then get the property data via the GetPropertyValue method
That's just perfect. Now it all works. Thank you very much !
Just for future reference. What's the difference between the two. And when do you use which one?
No worries, glad it worked out for you.
is working on a reply...