Fallback for kirbytext()

It would be nice to have the $field->or($alternative) work for the kirbytext() function.

What I would like to write would be: $myNewsletterText->kt()->or('Subscribe to our Newsletter').

In the absence of it, you could use the kirbytext() helper:

<?= kirbytext($page->newslettertext()->or('Subscribe to our Newsletter')) ?>
1 Like

Yes, that saves me a couple of lines -thanks :slight_smile:

This is also possible then:

<?= kirbytext($page->newslettertext()->or('Subscribe to (link: http://example.com text: our Newsletter)'));

After all, you can combine the kt() method with or(), provided your or() doesn’t contain a string but a field:

<?= $site->description()->or($page->text())->kt();

Therefore, this is also possible:

<?= $page->newslettertext()->or(new Field($page, null, 'Subscribe to our newsletter'))->kt(); ?>