Forum

Thread tagged as: Question

Strip carriage returns in meta description tags

I am using a perch_content_custom call on a list/detail setup to populate the page's meta description tag.

This is the field I am generating the meta tag from:

<perch:content id="p_product_description" type="textarea" textile="true" html="true" editor="markitup" label="Description" size="m" required="true" />

And this is the template used to display the meta tag:

<perch:content id="p_product_description" type="textarea" escape="true" striptags="true" chars="120" append="... (read more)" />

This works great, unless there is a line break in the p_product_description field before 120 characters. If there is, while the HTML tags are indeed stripped, a carriage return is retained. For example, the "view source" looks like this:

<meta name="description" content="This is an excellent, proven retaining wall block system.

This block is similar to the ever-popular Allan... (read more)" />

My understanding is that the meta description tag content should be included on a single line. Is it possible to strip these carriage returns on output? (I realize that ideally I would have a dedicated "meta" field for the author to fill out, but that may not be possible immediately.)

Thanks!

Richard Terrick

Richard Terrick 3 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

I'm not sure that's possible currently.

Ok, thanks Drew -- I will go ahead and pipe in the bespoke meta description field in the admin area instead.