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.phpfile 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
targetto your<a>tags, use thelinkstargetattribute on thetextareatag - To add a
targetto your<a>tags, use thelinksrelattribute on thetextareatag
<perch:content id="desc" type="textarea" filter="externallinks" linkstarget="_blank" linksrel="noopener" markdown>