Customizing PDF Templates With Smarty Modifiers


    Smarty™ is a template engine for PHP that allows users to make front-end presentation changes without the need to access the back-end code. The markup tags that can be used in Sugar® to add additional style and functionality to PDF and email templates are called Smarty modifiers. You can use Smarty modifiers to force formatting elements such as capitalization, hyphenation, and date style, or to transform your CRM’s field values into more customer-friendly terms. This article will walk through using a Smarty modifier to reformat a field on the system-generated PDF template in the Quotes module.

    Note: Smarty modifiers will not perform calculations, conditional logic, or allow you to modify the layout of a template. For those types of mathematical or logical modifications, you should utilize Sugar Logic and Calculated Fields.

    Use Case

    By default, quote templates in Sugar display 2 decimal values (to the hundredths) for the Quantity field. In this example, we will use a Smarty modifier to remove the decimal and trailing zeros when a quantity’s tenths and hundredths values equal zero (e.g., the quantity “2.00” becomes “2”, but “1.25” remains “1.25”).


    You must be an administrator user to access the PDF Manager in Sugar. We also recommend reviewing the Introduction to Smarty Modifiers for Sugar PDF Templates article. For the complete list of available modifiers, please refer to the official Smarty modifier documentation. 

    Steps to Complete

    1. Navigate to the System section of the Admin page and click “PDF Manager”.
    2. Open your organization’s standard template for the Quotes module, most likely titled “Quote”.
    3. From the Actions menu, click “Copy” to create a new version of the original Quote template.
    4. On the edit form, name the new template, “Quote – Extra Decimals Removed”.
    5. Place your cursor inside the template editor window and then press Ctrl+F (command+F on Mac) to launch the WYSIWYG’s Find/Replace dialogue window.
    6. Click the Replace tab. Find the text {$product.quantity}. Replace that text with {$product.quantity|replace:'.00':''}. Click “Replace All”. Wait for confirmation and then close the Find/Replace window.
    7. Click “Save” to preserve the changes to this new quote template.


    To test the new template, view a quote record that contains at least one line item with a whole number value. Find “Download PDF” in the Actions menu and click on the new template titled “Quote – Extra Decimals Removed”.

    Open the downloaded PDF file and confirm that the values displayed in the Quantity column do not display a decimal value for whole numbers.

    in PDF Management

    Reach out to us for help