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.

Weird image behaviour

January 21, 2009 11:58am

Subscribe [4]
  • #1 / Jan 21, 2009 11:58am

    spingh

    13 posts

    In my templete i have the following code:

    {if image}{image}{/if}

    Its works on all templates, except one :-(

    In that template it only doesn’t work in a certain spot.

    The error is that: if the image doesn’t exists, the whole
    template stops from rendering, no errors what so ever.

  • #2 / Jan 21, 2009 12:03pm

    Mark Bowen

    12637 posts

    Hiya,

    As you haven’t mentioned what you have exactly on the template where this doesn’t work then without some code example then this might be hard to fathom.

    Saying that however you should really be doing this instead :

    {if image !=""}
    {image}
    {/if}

    This is the more widely documented method for testing to see if a field has any content or not.

    Perhaps try changing the conditional to that first and see if it clears up the problem. I’m guessing however that it may not but we would need to see what code you are using on the page where it doesn’t work to be able to help any more. At a guess though you may have nested tags and something is a little funny somewhere.

    Hope that helps a bit though.

    Best wishes,

    Mark

  • #3 / Jan 21, 2009 12:04pm

    Sue Crocker

    26054 posts

    spingh, how does the template that works differ from the one that doesn’t?

    Which version and build of ExpressionEngine are you using? You can find that out at the bottom of any control panel page.

  • #4 / Jan 21, 2009 12:14pm

    spingh

    13 posts

    <h2 class="hl"><a href="http://{title_permalink={embed:my_template_group}/index}">{title}</a></h2>
    
    {if image !=""}{image}{/if}
    
    {if youtube !=""}
    
    <object type="application/x-shockwave-flash" style="width:600px; height:337px;" data="http://www.youtube.com/v/{youtube}">
    
    </object>
    {if:elseif videocode !=""}{videocode}{/if}
    <b>{summary}</b>
    
    {body}

    The only spot where “{if image !=""}{image}{/if}” works
    is after the “{videocode}{/if}”.

    EE Version 2.1.1 (20081028)

    The only difference is the video/youtube code

  • #5 / Jan 21, 2009 12:20pm

    spingh

    13 posts

    if i replace:

    {if image !=""}{image}{/if}

    with

    {if image !=""}test{if:else}test2{/if}

    The page renders fine, remember, there is NO image

  • #6 / Jan 21, 2009 12:24pm

    Sue Crocker

    26054 posts

    The field called image, what is default formatting of the file set to?

    If you remove the if test, and just put in {image}—what shows?

  • #7 / Jan 21, 2009 12:32pm

    spingh

    13 posts

    The field is: File, by Mark Huot (v.3.1.1) set to images only

    {if image !=""}test{if:else}test2{/if}

    works

    {if image !=""}{image}{if:else}{/if}

    doesn’t work

    {if image !=""}{image}{if:else}test2{/if}

    doesn’t work

    Remember, after the “video” code stuff, it does work.

  • #8 / Jan 21, 2009 12:40pm

    spingh

    13 posts

    <b>{summary}</b>
    {if youtube !=""}
    
    <object type="application/x-shockwave-flash" style="width:600px; height:337px;" data="http://www.youtube.com/v/{youtube}">
    
    </object>
    {if:elseif videocode !=""}{videocode}{/if}{image}

    Works

    {image}<b>{summary}</b>
    {if youtube !=""}
    
    <object type="application/x-shockwave-flash" style="width:600px; height:337px;" data="http://www.youtube.com/v/{youtube}">
    
    </object>
    {if:elseif videocode !=""}{videocode}{/if}

    Doesn’t work

  • #9 / Jan 21, 2009 3:22pm

    Robin Sowell

    13255 posts

    I’m not sure what all that extension is doing (and the vid one may be interacting as well).  If you try disabling all extensions via ‘Admin- Utilities- Extension Manager’- big green button on the top right- what happens?  Still an error?  (Or rather, a white screen.)

    Also- the white screen suggests a php error.  Make certain you have php errors showing to superadmin in ‘Admin- System Prefs- Output and debug’ and make sure you are logged in on the frontend when viewing.  An error would give us a hint.

  • #10 / Jan 21, 2009 4:38pm

    spingh

    13 posts

    I’m not sure what all that extension is doing (and the vid one may be interacting as well).  If you try disabling all extensions via ‘Admin- Utilities- Extension Manager’- big green button on the top right- what happens?  Still an error?  (Or rather, a white screen.)

    No error when i disable the file-extension, but i kinda expected that.

    Also- the white screen suggests a php error.  Make certain you have php errors showing to superadmin in ‘Admin- System Prefs- Output and debug’ and make sure you are logged in on the frontend when viewing.  An error would give us a hint.

    Its not a white screen, just the main content doesn’t render:
    So its only part of the included template that stops rendering without php error’s, mysql en template log show nothing different.

    header
    main (blank)
    footer

    Guess this post must be moved to the extension forum?

  • #11 / Jan 21, 2009 4:47pm

    Ingmar

    29245 posts

    It definitely looks like an issue with the “File” extension, yes. We don’t have to move the whole thread, though, perhaps it’d be easier to simply start a new thread there.

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

ExpressionEngine News!

#eecms, #events, #releases