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.png
    button.png
    5.8 KB · Views: 19

Kruzya

Well-known member
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>
 

Kruzya

Well-known member
Show how you inserted this code.
I insert button like this - via Template Modification system (/admin.php?template-modifications/), and all looks good.
1634456359624.png
1634456449287.png
 

Sirmadsen

Active member
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()">
 

Sirmadsen

Active member
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