If I don’t type anything in url blueprint, I hope a href does not work at the front end. What and how can I write in blueprints for that?
<a href="<?= $playlist->url() ?>" target="_blank">
If I don’t type anything in url blueprint, I hope a href does not work at the front end. What and how can I write in blueprints for that?
<a href="<?= $playlist->url() ?>" target="_blank">
Could you please rephrase and add some context?
When a user writes url, the site is moved to url.
There’s no problem here.
But I don’t want to be moved to url when the user doesn’t write url.
Is this possible? What can I do if possible?
You can use an if statement to check if the field is empty
<?php if ( $page->content()->get('url')->isNotEmpty()) : ?>
<a href="<?= $playlist->content()->get('url') ?>" target="_blank">
<?php endif; ?>
Note that url()
is a native Kirby method, so if your field is called url
, you have to fetch it via the content()
method, otherwise you will get the page url and not the url entered into that field.