Created
August 28, 2015 18:12
-
-
Save AugustMiller/29fbdee374a0c56a765d to your computer and use it in GitHub Desktop.
Quickly transform a Kirby email field into a clickable email link
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php field::$methods['asEmail'] = function($field) { | |
return html::a('mailto:' . $field->value, $field->value); | |
}; |
Frankly, not sure if there is a convention for naming fields. Kirby core tends to use toThing()
… But as
seems more neutral to me??
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can add this to
site/plugins
asfield-as-email.php
.Then, call it like this:
You'll get HTML that looks like this: