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')
.
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')) ?>
Yes, that saves me a couple of lines -thanks
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(); ?>