Template code for encrypted email link

Hi,

i am new to Kirby.

I have an email field in site.php.

fields:
email:
label: E-Mail
type: email

What code do i have to put into the template to get an encrypted mailto-email-link?

In the documentattion i only found something about email links within text fields. (email: info@example.com) e.g.

How does the same work with a link field (without encryption of course)?

Greetings,
René

You can use the email() method of the html class: https://getkirby.com/docs/toolkit/api/html/email

For a link, you can use html::a() : https://getkirby.com/docs/toolkit/api/html/a

Thank you texnixe.

Unfortunately these are the things i do not understand yet. I don’t know much about PHP, JQuery…
Can you give me a code example like “<?php…” to put into the template?

Yes, sure, here you go:

<?= html::email('mail@example.com', 'Contact us') ?>
<?= html::email($page->email()) ?>
<?= html::a('http://wikipedia.org', 'Wikipedia') ?>

The second parameter, i.e. “Contact us”, “Wikipedia”, is optional; if empty, the URL is used. You can also add an array of additional options, like a class etc.

3 Likes

It works!
Thank you very much, texnixe!