Skip to content

Instantly share code, notes, and snippets.

@koop-bremen
Forked from tobiasfabian/Panel Text
Last active August 21, 2016 10:44
Show Gist options
  • Save koop-bremen/d30bea0325efdc2c0bf0 to your computer and use it in GitHub Desktop.
Save koop-bremen/d30bea0325efdc2c0bf0 to your computer and use it in GitHub Desktop.
kirbytext: email with subject and body with linebreaks (\n)
<?php
kirbytext::$tags['email'] = array(
'attr' => array(
'text',
'subject',
'body'
),
'html' => function($tag) {
$email = $tag->attr('email');
$text = $tag->attr('text', $email);
$subject = rawurlencode($tag->attr('subject',null));
$body = $tag->attr('body',null);
$body = rawurlencode(str_replace('\n', "\n", $body));
$query = ($subject || $body) ? '?' : '';
$query .= ($subject) ? 'subject='.$subject : '';
$query .= ($subject && $body) ? '&' : '';
$query .= ($body) ? 'body='.$body : '';
return '<a href="mailto:'.$email.$query.'">'.$text.'</a>';
}
);
(email: [email protected] subject: reserve tickets body: Hi!\n I need the following tickets:\n\n\nBest,\n)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment