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
Hi,
I have a page on my site with a list of sub pages, I want to link to the sub pages by puilling out an image and wrapping it in an achor.
The trouble with the code below is it displays
<a href="link01"> <img src="image01"> <img src="image02"></a><a href="link02"> <img src="/image01"> <img src="image02"></a>
Instead of
<a href="link01"> <img src="image01"></a><a href="link02"> <img src="image02"></a>
Here is my code
@foreach (var page in @Model.Children) { <a class="fancybox" href="@page.Url"> @foreach(var pressimg in Model.Children) { <img src="@pressimg.Media("pressImage", "umbracoFile")" alt="@pressimg.Name"/> } </a> }
Well you've got nested foreach loops that are both looping through the current pages children. If I understand what you're trying to do, you can probably do this all in a single foreach loop:
@foreach (var page in Model.Children){ <a class="fancybox" href="@page.Url"> <img src="@page.Media("pressImage", "umbracoFile")" alt="@page.Name"/> </a>}
Thats done it.. thanks!
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Razor script, pulling image from child page
Hi,
I have a page on my site with a list of sub pages, I want to link to the sub pages by puilling out an image and wrapping it in an achor.
The trouble with the code below is it displays
<a href="link01">
<img src="image01">
<img src="image02">
</a>
<a href="link02">
<img src="/image01">
<img src="image02">
</a>
Instead of
<a href="link01">
<img src="image01">
</a>
<a href="link02">
<img src="image02">
</a>
Here is my code
Well you've got nested foreach loops that are both looping through the current pages children. If I understand what you're trying to do, you can probably do this all in a single foreach loop:
Thats done it.. thanks!
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.