How to control the length of dynamic text blocks

Some of the content in your email automations (especially product recommendations) is pulled dynamically from your product catalog. This saves you lots of time and effort, but since the product titles may vary greatly in length, may introduce email design issues such as an uneven number of rows.

There are 2 different "modifiers" you can use with smart tags within Remarkety to control the maximum (and minimum length) of length of dynamic text: "truncate" and "fixlen". The difference is that "truncate" will trim long strings but will not modify short strings, whereas "fixlen" will trim long strings and pad shorter strings with spaces so that you can be sure of the exact text length ahead of time. "truncate" will also take care to completely leave out the last word if it won't fit.

Both modifiers accept an optional parameter for the resulting string length. It's always a good idea to provide this and not rely on the defaults. The parameter is specified by adding ":<length>" to the modifier.

Example usage:

In this example, we are displaying the product recommendations' product title. The recommendation titles are always in {$r[0].title}, {$r[1].title}, etc. Let's assume that the product title in this case is 32 characters long: "This is an awesome product title"

Tag

Result

Explanation 

{$r[0].title}

"This is an awesome product title"

The original text

{$r[0].title|truncate:20}

"This is an..."

Truncated to less than 20 chars because "awesome" wouldn't completely fit at the end

{$r[0].title|truncate:21}

"This is an awesome..."

Truncated to 21 chars, including the additional "..." added at the end

{$r[0].title|fixlen:20}

"This is an awesom..."

fixlen doesn't mind partial words

{$r[0].title|fixlen:21}

"This is an awesome..."

 

{$r[0].title|truncate:40}

"This is an awesome product title"

The string is less than 40 chars, so truncate does nothing

{$r[0].title|fixlen:40}

"This is an awesome product title        " The string was too short, so fixlen padded it with spaces
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.