LogoLogo
HomepageDocumentationGet FeedOtter
  • Welcome to FeedOtter
  • Automated Newsletters
    • Getting Started
      • Marketo Sending
      • Pardot Sending
      • Eloqua Sending
      • SFMC Sending
      • HubSpot Sending
      • MailChimp Sending
      • Active Campaign Sending
    • Scheduling Your Send
      • Require New Content to Send
      • Intervals
    • Features
      • Last Send Date
      • Send Now
      • Sending History
      • UTM Parameters
      • Custom Subject Lines
      • Notifications
      • Multiple Feeds
        • Merging Feeds
        • Pulling in External JSON/XML Data
  • Curated Newsletters
    • Getting Started
      • Newsletter Defaults
      • Adding Content Sources
      • Create your first curated issue
      • Test, Review, and Publish your curated email newsletter
    • Publishing
      • Publishing to Marketo
        • Create a New Email Program and Email
        • Create a New Email in Marketo
        • Schedule an Email Program Send From the FeedOtter Interface
      • Publishing to Pardot
      • Publishing to Eloqua
        • Create a New Email and Schedule a Send
        • Create a New Email
        • Update an Existing Email
        • Issue Naming
      • Publishing to HubSpot
      • Publishing to MailChimp
      • Publishing to HTML
    • Tags
    • Bookmarking Content
    • Content Sources
      • Google Sheets
      • YouTube
      • Algolia
      • WordPress API
      • UberFlip
      • JSON / XML API
        • Custom Data Fields
    • Troubleshooting
      • Marketo Duplicate Object Naming
      • Marketo Emoji Support
      • MailChimp From Address
      • Pardot emails are missing a required Unsubscribe or Preference Center tag
  • Integrations
    • Getting Started
    • Marketo
      • How to Set Up Your Marketo Integration
      • FAQ
        • Email Reporting
        • Sending in Recipient Time Zone
        • Marketo Data Access
        • Custom Marketo Program Naming
        • Branded Domain and IP Settings
      • Troubleshooting
        • How do I reset my Marketo Automated Campaign
        • Marketo Error: Program with the same name exists
        • Marketo error: Daily quota '50000'
        • Marketo Error: Invalid request. Please check and try again.
        • Curated Issue Fails to Publish
          • FeedOtter Can Not Approve Marketo Template
          • Marketo rejects Duplicate Name
      • Exporting a FeedOtter email into Marketo
    • Pardot / Account Engagement
      • How to Set Up Your Pardot Integration
      • FAQ
        • Salesforce IP Whitelisting
        • Where Can I Find My Pardot Business Unit ID?
        • Pardot Data Access
        • Advanced Settings
          • Set Up a User for Integration
      • Troubleshooting
    • Eloqua
      • How to Set Up Your Eloqua Integration
      • FAQ
        • Custom Email and Campaign Naming
        • Custom Field Setup
        • Updating Eloqua Canvas Email
        • Eloqua Data Access
        • VMTA and BBE
    • Salesforce Marketing Cloud
      • How to Set Up Your SFMC Integration
      • FAQ
        • SFMC Tracking Code
        • SFMC Resources and Links
      • Troubleshooting
    • HubSpot
      • How to Set Up Your HubSpot Integration
      • FAQ
      • Manually publish an email to HubSpot
    • MailChimp
      • How to Set Up Your MailChimp Integration
    • ActiveCampaign
      • How to Set Up Your ActiveCampaign Integration
    • Microsoft Dynamics Marketing
      • How to Set Up Your MS Dynamics Integration
  • Email Templates
    • Getting Started
      • Custom Template
        • HTML Email Guidelines
          • In-Depth HTML Email Guidelines
        • Custom Template Resources
          • ESP Template Use
            • Export a Marketo Template for Use in FeedOtter
            • Export a Pardot Template for Use in FeedOtter
            • Export a HubSpot Template for Use in FeedOtter
            • Export an ActiveCampaign Template for Use in FeedOtter
        • Where to Access Template Code
        • Getting Started with FeedOtter Templates
          • Creating a Basic Email Template
          • Advanced Email Templates
            • Slicing loops
            • Multiple Feed Emails
            • Email With Columns
            • Conditionals
            • Filters
              • Image Resize Filter
              • Date Formatting Filter
              • Text Manipulation Filters
              • Other Handy Filters
            • Non-RSS XML values
            • Custom fields
            • Display a Full Article in Your Email
          • Curated Email Setup Best Practices
            • Curated Newsletter Sections
      • Element Customization
        • About Email Images
    • FeedOtter Tokens
    • ESP-Specific Tokens
      • Marketo Tokens
        • Using Marketo Tokens in the From and Reply-To
      • Pardot Tokens
        • Pardot Merge Token Reference
      • Eloqua Tokens
      • SFMC Tokens
      • HubSpot Tokens
      • MailChimp Tokens
      • ActiveCampaign Tokens
  • Account Management
    • Account Information
    • Company Details
    • Manage Users
      • Adding Users
      • User Roles
      • Campaign Permissions
      • Transfer Ownership
      • Disabling Users
    • Security
      • Enable SSO in Your Account
        • Enable SSO With Okta as the Identity Provider
        • Enable SSO with a Generic Identity Provider
        • Enable SSO with Azure AD as the Identity Provider
        • Enable SSO with OneLogin as the Identity Provider
      • Account Level 2FA
    • Billing
      • Update Your Payment Card
      • View Account Usage
      • View Receipts
      • Change Your Subscription Plan
  • FAQ
    • How to manually publish a curated newsletter
    • WordPress RSS Feed Reference
    • How to find your RSS feed
    • Help with HTML encoding
    • My automated email did not send as expected
    • How do I hard refresh my browser?
    • How to Remove "This Post First Appeared" from Your Blog's RSS Feed in WordPress
    • Whitelisting FeedOtter
    • Whitelist FeedOtter on CloudFlare
    • How do I contact support?
    • Red Dot: Campaign Status
      • Confirm your RSS Feed is valid
      • Confirm your integration is still connected
Powered by GitBook
On this page
  • Basic IF
  • Basic If/Else
  • Ternary If/Else
  • Popular Use Cases
  • Hide if there is no content in a post loop
  • Hide if we are at the last entry in a loop
  • Hide an image if there is no image value
  • Even/Odd
  1. Email Templates
  2. Getting Started
  3. Custom Template
  4. Getting Started with FeedOtter Templates
  5. Advanced Email Templates

Conditionals

Use IF/ELSE statements in your FeedOtter emails to show/hide elements based on the presence of content or property values.

Often it is desirable to show/hide content based on whether tag values are present. Using conditional if/else statements allow you to hide certain content based on other factors in your email. Let's walk through a few examples:

Basic IF

[% if post.image_url == true %]
<img src="[[post.image_url]]">
[% endif %]

The example above tells FeedOtter if there is an image available, to show the <img src> block in the email. If FeedOtter cannot find an image to pull into your email, it will hide this block altogether.

This can be helpful for showing/hiding banners, ad content, or even full tables of content in your HTML email.

Basic If/Else

[% if post.image_url %]
<img src="[[post.image_url]]">
[% else %]
<img src="http://placehold.it/600x400">
[% endif %]

This tells FeedOtter to pull the image from your feed content if available, but if FeedOtter cannot find a suitable image to pull, the [% else %] statement provides a default image to fall back on. So, when some posts may not have a featured image to pull, the placeholder image will appear in your email.

Ternary If/Else

[[post.image_url ? post.image_url : 'http://placehold.it/600x400']]

Providing the same outcome as the if/else statement above, this provides FeedOtter a default image to show in case your content doesn't contain images. Rather, instead of wrapping your image block with a conditional, the full string above will go into the quotation marks on your <img src="">. This works with more than just images, and can include default text when none is provided by the feed.

Popular Use Cases

Hide if there is no content in a post loop

Use this for content in your HTML email template that you want to be displayed only if there is content displayed from your feed here. Most commonly seen when there are headlines or divider lines for content blocks that you want displayed for the content.

[% if feedotter.posts |length >0 %]
//display something
[% endif %]

Hide if we are at the last entry in a loop

What this conditional is saying is "if the loop index (number of repeated block) is equal to the loop length (this will be the last repeated block), hide what the below content.

In this case, you would wrap the conditional around the >hr> so that it doesn't display after the last post in a loop.

<!--## [% if loop.index != loop.length %] ##-->
<hr>
<!--## [% endif %] ##-->

Hide an image if there is no image value

<!--## [% if (post.image_url) ##-->
<img src="[[post.image_url]]">
<!--## [% endif %] ##-->

Even/Odd

Useful for alternating designs.

<!--## [% if loop.index0 is even %] ##-->
//display image-right content block
<!--## [% endif%] ##-->

<!--## [% if loop.index0 is odd %] ##-->
//display image-left content block
<!--## [% endif %] ##-->

We see a number of templates that have content blocks that alternate the text/image. See the image below as an example of when you would use this conditional statement.

Last updated 2 years ago