This is a Perch template filter that allows you to add target
and rel
attributes to external links inside textarea
field types.
- Download the latest version of the template filter
- Unzip the download
- Place the
PipitTemplateFilter_externallinks.class.php
file in the folderperch/addons/templates/filters/
- Include the class in the file
perch/addons/templates/filters.php
:
include('filters/PipitTemplateFilter_externallinks.class.php');
You also need to enable template filters in your config:
define('PERCH_TEMPLATE_FILTERS', true);
Specify the site URL in your config.php
:
define('SITE_URL', 'https://example.com');
If the above isn't present, the filter will use the site URL entered in Perch's Settings in the contorl panel.
- Specify the filter with
filter="externallinks"
- To add a
target
to your<a>
tags, use thelinkstarget
attribute on thetextarea
tag - To add a
target
to your<a>
tags, use thelinksrel
attribute on thetextarea
tag
<perch:content id="desc" type="textarea" filter="externallinks" linkstarget="_blank" linksrel="noopener" markdown>