How Tos

Customizing Snipe – Changing email templates

Snipe is a great open source asset management tool ideal for organisations and educational environments where you want to be able to lend out devices and track maintenance schedules. I’ve posted a few articles about how to configure Snipe already and in this article I’ll look at how to customize the emails that Snipe sends out, particularly the email receipts when someone checks in or out an asset.

In my previous guide I’ve looked at installing Snipe on Ubuntu, so I’ll carry on working on my Ubuntu box. If you are running on Snipe on Windows, or you’ve installed it in a non-default directory, then the following guide should give you a rough idea as to where to look and you’ll need to adjust the locations based on your setup.

[message type=”error” title=”Warning”]Future Snipe updates may overwrite your modified files. Be sure to grab a backup of your changes so that you can easily restore them if you need to. [/message]

The template files

Snipe uses templates heavily so that you can customize a number of its emails and pages. Here’s a rough list of the email templates and their file names. The paths are relative to the Snipe install folder so in our case they all start /var/www/snipeit/.

[table]

Description, Filename
The header used in every email, /app/views/emails/layouts/default.blade.php
When a user receives or accepts a loan device,/app/views/emails/accept-asset.blade.php
When a user requests a loan device,/app/views/emails/asset-requested.blade.php
When a user checks in a loan device,/app/views/emails/checkin-asset.blade.php
When the loan period of a device is about to expire,/app/views/emails/expiring-assets-report.blade.php
When the loan period of a license is about to expire,/app/views/emails/expiring-licenses-report.blade.php
When the user requests a password change, /app/views/emails/forgot-password.blade.php
When the user registers or activates their account, /app/views/emails/register-activate.blade.php
When an administrator creates an account for a user, /app/views/emails/send-login.blade.php
[/table]

Editing the templates

I’ll be using Emacs here as my editor in Ubuntu but feel free to use whatever editor you like. One that’s available on every system is vi, but you’ll want to open up this list of handy vi commands if you don’t know it.

  1. So assuming you’ve logged on to your Ubuntu server, let’s change to that base directory.
  2. cd /var/www/snipeit

  3. I want to my logo to the header of each email so let’s first make a copy of the default email blade file.
  4. cp /app/views/emails/layouts/default.blade.php /app/views/emails/layouts/default.blade.php.bak

  5. Next lets open up the default blade file.
  6. sudo emacs /app/views/emails/layouts/default.blade.php

  7. Now you can see the default.blade.php file where you can add elements to the top of your emails. To add an image to the top of your emails you can add the following line just before the @yield line.

  8. It should look like this


    @yield('content')

  9. Finally, copy the default blade template file to your Home directory just in case an update overwrites it.
    cp /app/views/emails/layouts/default.blade.php ~
  10. When you next check in or check out an email your email should show you a lovely logo.
    snipe_template-logo

What is your reaction?

Strongly Agree
0
Agree
0
Meh
0
Disagree
0
Strongly Disagree
0

You may also like

2 Comments

  1. Excellent, thank you!

    1. Pleasure 🙂

Leave a reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.

More in:How Tos