XF 2.2 Add additional download button

Sirmadsen

Active member
How would one be able to add a second download button tied to a resource field? I got the class and button all set up but where in the templates would I have to edit to add the button and what should I add? The resource field is set to be an external URL but I want it to be a button of the field have text in it.

The field id is "download_manual"
 

Attachments

  • button.webp
    button.webp
    2.7 KB · Views: 29
Template xfrm_resource_wrapper_macros
Find: <xf:if is="$resource.canDownload()">
Add below:
HTML:
<xf:if is="$resource.custom_fields.download_manual is not empty">
    <xf:button href="{$resource.custom_fields.download_manual}">
        {{ phrase('your_site.download_manual') }}
    </xf:button>
</xf:if>
 
With a bit added to make it look like the other download button it looks like this. I just changed the template directly, I don't know how to use the template modification system.
Code:
</h1>
    <xf:if is="$resource.custom_fields.download_manual is not empty">
        <xf:button href="{$resource.custom_fields.download_manual}" target="_blank"
                   rel="noopener"
                class="button--cta"
                icon="download">{{ phrase('download_manual') }}</xf:button>
    </xf:if>
                        <xf:if is="$resource.isDownloadable()">
 
I installed the allow template modifications addon but it's the same problem. As soon as the "Does not have a file" option is used the button is not showing up. And if I move the code to look like the one above the buttons are not aligned.
So in short, this button should always be visible no matter what resource type, unless the custom field is empty.
 
Last edited:
Top Bottom