Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
So, I've got a form set up in the staff section of my project for new catalog additions to be posted to the public portion of the website. In order for things to display correctly, there has to be a way to check for the presence of the securefile, as not every addition will have an image to attach. From the <cms:dump /> information, though, there's no variable that can be used in the <cms:pages> tag to check for the presence of the securefile (the field name variable for the secure file is null regardless of the presence of a file), and within the <cms:show_securefile> tag any page without the securefile is skipped completely.

I could add an additional field to the form, but that feels cumbersome compared to checking for the presence of the file. Is there some bit of documentation I'm missing?
The cms:show_securefile tag, used to display the attachment, itself serves to indicate the presence/absence of an attachement e.g. in the following code anything between the <cms:show_securefile..></cms:show_securefile> tags will execute only if there is an attachment.
Code: Select all
<cms:show_securefile 'imagefile' >
    <cms:if file_is_image >
        <a href="<cms:cloak_url link=file_id />">
            <img src="<cms:cloak_url link=file_id  />" />
        </a>
    </cms:if>
</cms:show_securefile>

If required, you can set another variable to denote the same thing for use elsewhere on the page e.g.
Code: Select all
<cms:show_securefile 'imagefile' >
    ...
    <cms:set has_attachement='1' 'global' />
</cms:show_securefile>
...
...
<cms:if has_attachement>
    ..
<cms:else />
    ..
</cms:if>

Hope this helps.
Thanks! I think the second example is what I was trying to do; I'll try it out and see.

Thanks,
Sam
3 posts Page 1 of 1

Who is online

In total there are 2 users online :: 1 registered, 0 hidden and 1 guest
(based on users active over the past 5 minutes)

Users browsing this forum: Majestic-12 [Bot] and 1 guest