0

I have a 'projects' channel, that contains a 'Channel Images' field. An entry can belong to one of four categories.

On my home page, all I want to display is two of the images from the most recently added project. When you click on either small image it directs to the page of that entry.

I cannot work out how to display the two images from just the one category. My code below displays one image from one entry belonging to each category. How do i limit it to only display the image (2) from the latest entry (whatever category it belongs to)?

{exp:channel:categories channel="project" style="linear"}
{exp:channel:entries channel="project" category="{category_id}"  disable="pagination|member_data" limit="1"}

<div class="{switch="w1|w2"}"><a href="projects/{category_url_title}/{url_title}" title="{title}">{proj_img}<img src="{image:url:sml}" alt="{image:title}" width="112" height="112" border="0" />{/proj_img}</a></div>

{/exp:channel:entries}
{/exp:channel:categories}

Any help is very appreciated.


Update: Kerry's answer below is close to correct, i had to make a slight alteration.

{exp:channel:entries channel="project" disable="pagination|member_data" limit="1" parse="inward"}
{exp:channel_images:images entry_id="{entry_id}" field="proj_img" limit="2" sort="asc"}
  <div class="{image:switch='w1|w2'}">
    <a href="projects/{categories}{category_url_title}{/categories}/{url_title}" title="{title}">
      <img src="{image:url:sml}" alt="{image:title}" width="112" height="112" border="0" />
    </a>
  </div>
{/exp:channel_images:images}
{/exp:channel:entries}
0

1 Answer 1

1

If you're just pulling the latest entry from the Project channel without any category restrictions and want to pull the latest 2 images from that latest entry, and your categories are only 1 level deep, you can try this:

{exp:channel:entries channel="project" disable="pagination|member_data" limit="1" parse="inward"}
    {proj_img limit="2"}
        <div class="{image:switch='w1|w2'}">
            <a href="projects/{categories}{category_url_title}{/categories}/{url_title}" title="{title}">
                <img src="{image:url:sml}" alt="{image:title}" width="112" height="112" border="0" />
            </a>
        </div>
    {/proj_img}
{/exp:channel:entries}
1
  • 1
    Thanks for your response. the {proj_img} field tag did not work, but i changed it to the 'channel images' tag and got it to work as needed. Thanks again!
    – ZEDG
    Aug 18, 2014 at 6:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.