0

I'm trying to make a "previous" button link dependent on a couple of conditions: 1) if there's a previous image, it links to that; 2) if there is no previous image, it goes to the main portfolio page. Here's my basic code:

{image:paginate}
        {if image:previous_page}<a href="{image:auto_path}">
        {if:else}<a href="{site_url}portfolio">{/if}
            <img src="{site_url}images/arrow-back.png" alt="previous"></a>
{/image:paginate}

But when I try this, I get an error code:

Parse error: syntax error, unexpected T_ELSE....

Any thoughts on either what's wrong or how to do this properly?

Thanks in advance....

  • It looks like devdemon's fault. Are eecms and channel images up to date? – Robson Sobral Jun 17 '15 at 21:25
0

I think I see what the problem is now. I looked more closely at the documentation, and for the {image:previous_page} tag it says

This tag will conditionally display the code inside the tag if there is a “previous” page. If there is no previous page then the content simply will not be displayed. (In the {image:paginate} tag pair)

So I think since there is no "previous" page, then the {if:else} part is not displayed (at least this is my theory). So what I've done to make this work is this:

{image:paginate}
    {if image:previous_page}<a href="{image:auto_path}">{/if}
    {if {image:current_page} == 1}<a href="{site_url}portfolio">{/if}
        <img src="{site_url}images/arrow-back.png" alt="previous"></a>
{/image:paginate}

This is working for me. I do recall at some point that {if:else} was just not working in Channel Images, and when I was pursuing the question some time ago, there was never a resolution. I don't know if {if:else} will work now in Channel Images or not (I have 5.14.8). But with the new support system from DevDemon, I'd have to pay to find out.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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