We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Fetching the first entry in a grid

How Do I?

Linda A's avatar
Linda A
666 posts
3 years ago
Linda A's avatar Linda A

I am trying to populate the og:image meta tag. My template uses a fluid field (westeros_data) which has includes the ability to add single images or file grids of images. A post may have neither, either or both. If there’s neither, og:image gets no data (I am considering assigning a default image, however). If there’s either, og:image should get either the first single image or the first image from the grid. If there is both, og:image shoiuld get the first single image.

I have it working so it fetches the first single image:

{westeros_data}{westeros_data:westeros_image}{if {westeros_data:count name="westeros_image"} == "1"}{content}{content:image}{/content}{/if}{/westeros_data:westeros_image}

But I am not sure how to grab a single image from a file grid or to create a conditional in the case where a post has both a single image and a file grid with images.

       
Linda A's avatar
Linda A
666 posts
3 years ago
Linda A's avatar Linda A

Ah, figured out part of it. The limit = “1” parameter gets put on {content}. Next step, a conditional so it doesn’t fail when there’s both a standalone image and a slideshow.

? 1
       
javiercoleman's avatar
javiercoleman
1 posts
3 years ago
javiercoleman's avatar javiercoleman

You can check Texas Kitchen Hood Cleaning website for the same samples. And while at it, you can check the services in your area.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.