Home

Appendix

Application Icon   Smart Templates

Some of the DEVONthink provided templates are "template packages" (.dtTemplate) and "smart templates" (.templatescriptd). Both templates provide a great deal of flexibility and power, like allowing for inclusion of language resources. With some creativity and scripting know-how, you can set up everything from commonly used group hierarchies to daily journal entries and much more.

Template packages

The simpler type of automated templates DEVONthink supports are: template packages. These are folders with the file name extension .dtTemplate that contain one or multiple .lproj folders, one for each supported language. Depending on the system language, you can let DEVONthink import the files in the correct language. If you inspect the contents of a template package, e.g., Classifications > Decimal Filing System.dtTemplate, you will see the project folders and their assets as a great example of this type of template.

Smart templates

The more advanced type of automated templates are smart templates. These are not simple files, but actually AppleScript packages containing script code, and often including related assets that can be inserted into your database. This allows for some very powerful actions like:

  • Icon
    The script can add information to the built-in template, e.g., the current date and time or data from the web.
  • Icon
    The script can act intelligently on data on the clipboard: If it's a simple text, it adds the text; if it's a URL, it adds it to a different area of the document and makes it clickable.
  • Icon
    The script can check if a certain application is installed, e.g., OpenOffice, before adding a document.

Creating Templates

Template Packages: To create your own template package, you can duplicate an existing template, Control-click it, choose Show Package Contents and edit the internals as needed. Also note exporting multiple selected files will yield a template package.

Smart Templates: To make your own smart templates, have a look at the prefabricated smart templates. Duplicate a .templatescriptd file, like the "Note" template. Control-click it, and choose Show Package Contents. You can inspect and modify the supporting assets and the main.scpt file to fit your needs.

Template Placeholders

Placeholders in templates are simple control codes that are replaced by DEVONthink when a template file is imported. These placeholders can be used in your files, including simple templates, or folder names of your templates packages. When used in files, they are typed in the text of DEVONthink-native files; e.g., plain or rich text, Markdown, etc. These can be manually typed or you can Control-click in the text and choose Insert Placeholder. Below is a list of valid placeholders:

  • Icon
    %time%: The current time
  • Icon
    %date%: The current date
  • Icon
    %shortDate%: The current date in short format
  • Icon
    %longDate%: The current date in long format
  • Icon
    %monthname%: The month name of the current date
  • Icon
    %weekday%: The week day name of the current date
  • Icon
    %day%: The day number of the current date
  • Icon
    %month%: The month number of the current date
  • Icon
    %year%: The year number of the current date
  • Icon
    %author%: The author entered in Preferences > Editing > Author
  • Icon
    %username%: The user's name
  • Icon
    %fullUsername%: The user's full name
  • Icon
    %organization%: The user's organization from Contacts
  • Icon
    %emailAddress%: The user's email addresses from Contacts
  • Icon
    %host%: The host name
  • Icon
    %databaseName%: The database name
  • Icon
    %databasePath%: The database's path
  • Icon
    %groupName%: The name of the parent group
  • Icon
    %topGroupName%: The name of the top group
  • Icon
    %clipboard%: The clipboard contents as plain text
  • Icon
    %styledClipboard%: The clipboard contents as rich text
  • Icon
    %clipboardLink%: The clipboard contents as a clickable rich text link if the clipboard contains a valid URL

Note: There are more placeholders from the contextual menu than can be used in a template. For example, the placeholder %record_locality% relates to an existing record, so this placeholder will not be used when creating a file from a template.

Custom Placeholders: One more powerful feature of smart templates is the ability to define custom placeholders, extending the possibilities beyond the list shown here. This allows you to add a custom placeholder in the text of a template, then define the replacement value for that placeholder in the main.scpt. As a great example, check out the use of the custom %project% placeholder in the Project smart template. Notice the use of the placeholder in the enclosed rich text file and the script.

Terminology

With the internal script of a smart template, there are no special handlers required. However, the internal script must be located in the Contents/Resources/Scripts folder inside the package, and it must remain named main.scpt. Beyond that, you only need valid AppleScript.

Toolbar Templates

To add any template to the toolbar, place the template into the folder ~/Library/Application Support/DEVONthink 3/Templates.noindex/Toolbar. In order for the script to be available for use in the toolbar, you must quit and relaunch DEVONthink. Then Control-click the toolbar of a DEVONthink window and choose Customize Toolbar. Drag your template into the toolbar and it's ready for use.