I have a channel named Projects, and within that channel i have a 'channel images' field (p_feature). It allow the user to upload one image, and if they do so that image will appear on the Home page as part of a carousel slider. ..So a 'feature' image is not uploaded for every Project entry, but only the ones the user wants featured on the home page.
Below is how the html looks:
<div class="slider-wrapper theme-default">
<div class="ribbon"></div>
<div id="slider" class="nivoSlider">
<img src="1.jpg" data-thumb="1.jpg" alt="" title="#htmlcaption1" />
<img src="2.jpg" data-thumb="2.jpg" alt="" title="#htmlcaption2" />
</div>
<div id="htmlcaption1" class="nivo-html-caption">Title 1 <a href="#">Link 1</a></div>
<div id="htmlcaption2" class="nivo-html-caption">Title 2 <a href="#">Link 2</a></div>
</div>
The Captions appear below the slider div, and also link to the Project.
So my code produces the image, but i'm not sure how to produce the caption (project title & url) that relates to the feature image uploaded.
Plus because the captions (have to) appear outside of the slider div, do i have to open the channel entries tag again?
So something like this:
<div class="slider-wrapper theme-default">
<div class="ribbon"></div>
<div id="slider" class="nivoSlider">
{exp:channel:entries channel="project"}
{if p_feature}
{exp:channel_images:images channel="project" entry_id="{entry_id}"}
<img src="{image:url:carousel}" data-thumb="{image:url:carousel}" alt="" title="#htmlcaption{entry_id}" />
{/exp:channel_images:images}
{/if}
{/exp:channel:entries}
</div>
{exp:channel:entries channel="project"}
{if p_feature}
{exp:channel_images:images channel="project" entry_id="{entry_id}"}
<div id="htmlcaption{entry_id}" class="nivo-html-caption">{title} <a href="/projects/{url_title}">Read More</a></div>
{/exp:channel_images:images}
{/if}
{/exp:channel:entries}
</div>
Plus is there a way to 'automatically' add ascending numbers? I would need that for the #htmlcaption1, #htmlcaption2, #htmlcaption3 etc.
Any help is greatly appreciated!
UPDATE: Code has been updated with working solution.