ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Check the existence of a field

July 08, 2011 2:07pm

Subscribe [2]
  • #1 / Jul 08, 2011 2:07pm

    benjyrose

    16 posts

    One of my Channels has two custom fields: photo and photo_homepage. photo is the photo for the actual page, and photo_homepage is for the little blurb & thumbnail when the page is featured on the homepage.  There are two photos in case the client wants to use a different thumbnail on the homepage than on the page itself.

    So, on the homepage, I want an if statement…something like:

    {if [photo_homepage exists]}
    <img >
    {if:else}
    <img >
    {/if}

    How do I check to see if photo_homepage exists?

    thanks,
    benjy

  • #2 / Jul 08, 2011 2:44pm

    Mark Bowen

    12637 posts

    Hi Benjy,

    You’re actually very close with what you have there :

    {if photo_homepage != ""}
    {photo_homepage}
    {if:else}
    …other image source code…
    {/if}

    Unless your small and large images are completely different then I’d definitely recommend looking at using something like the CE Image plugin as this will then allow you to only upload the one larger image and then create your smaller image on the fly dynamically.

    Like I say if the images are exactly the same (just smaller) then this add-on really is one of the best add-ons you can ever install for ExpressionEngine and will save hours of time literally.

    Hope that helps a bit anyway.

    Best wishes,

    Mark

  • #3 / Jul 08, 2011 3:25pm

    benjyrose

    16 posts

    Awesome…thanks! I’ll take a look at that add-on, too.

  • #4 / Jul 08, 2011 4:58pm

    Mark Bowen

    12637 posts

    Awesome…thanks! I’ll take a look at that add-on, too.

    No problem at all.

    Hope everything else goes well for you.

    Best wishes,

    Mark

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases