Wiki
Clone wikiPerch Resource Wiki / Remove-White-Space-from-Callto-Links
Remove White Space from Callto Links
This example removes white space from text that client enter into a text field, and hence can be used to create valid callto:
links for example. If you create user editable company details that are displayed around the site with shared regions for example. Phones numbers need to be formatted in a string of numbers, however for display purposes, you often wish to have the number broken up to make them easier to read.
This will result in the following code being formatted correctly:
<a href="callto:01234567890">01234 567 890</a>
Step 1: Create filter
The first step is to place the following in perch/addons/templates/filters.php
:
<?php class PerchTemplateFilter_nospace extends PerchTemplateFilter { public function filterAfterProcessing($value, $valueIsMarkup = false) { return str_replace(' ', '', $value); } } PerchSystem::register_template_filter('nospace', 'PerchTemplateFilter_nospace');
Step 2: Add filter tag
On any text tag you want to remove regular space from, simply add filter="nospace"
to the tag. In this example will use the following:
<a href="callto:<perch:content id="landline_number" type="text" label="Landline phone number" help="01234 567890" filter="nospace">"> <perch:content id="landline_number" type="text" label="Landline phone number" help="01234 567890"> </a>
Step 3: Define in config file
The last step is to tell Perch or Runway that you are using a Template Filter, in your config.php
file, add the following:
define('PERCH_TEMPLATE_FILTERS', true);
Updated