Url field returning page url not external url's

Hi all, can the url field be used to display (link to) external urls or is it only for internal? Reason I ask is that when I use the url field in the blueprint, even with a valid url entered into the field and appearing in page txt file, the template outputs only the url of the page, not the url entered in the panel.

Relevant part of blueprint is:

fields:
url:
label: Public link
type: url

Output as per the two examples in the Kirby Docs:

<?= $page->url() ?>

Returns only the url of the page, not the entered value.

<?= $page->url()->toLink() ?>

This results in an error: Call to a member function toLink() on string.

By contrast the link field works perfectly.

I have no doubt this a mistake on my part, missing values etc, but any guidance welcome.

Thanks.

$page->url() id a core method, so this one is actually calle, not your field. Best to use a different field name.

See Fields | Kirby CMS

Cheers, based on you link you sent and @distantnative’s suggestion re a different name both the following work and display the entered url rather than the page url, thanks to you both:

<?= $page->cal_url()->html() ?>
<?= $page->cal_url()->kirbytext() ?>

However this:

<?= $page->cal_url()->toLink() ?>

Displays the correct link but still clicks to the actual page rather than the entered link. What is the best way to add the cal_url value to the “toLink()“… assuming that makes sense.

I realise this is probably a basic php question.

Both toLink and kirbytext field methods don’t make sense for an url field