Can you share more of your code and the blue print? Where is the data stored? How are you setting $navcta
.
I asked a similar question a couple of years ago, maybe this thread holds the answer… Specific entry in a structure field
It might be over kill for what you want but i do CTA links via a kirby route to get a list of every page on the site, and using that as an option list on a select field. This saves you having to store the links in a structure feild, and is completly dynamic.
The route will look something like this (im using AutoID but should be easy enough to switch this to UID or something):
// Page Links
array(
'pattern' => 'pagelist.json',
'action' => function() {
header('Content-type: application/json; charset=utf-8');
$pages = site()->index()->visible()->filterBy('template', 'not in', ['error', 'blogarticle']);
$json = array();
foreach ($pages as $page) {
$json[$page->autoid()->value()] = $page->title()->value();
}
echo json_encode($json);
}
),
You can then pump that list into a Select field:
ctalinkurl:
label: Button Link
type: select
options: url
url: pagelist.json
width: 1/2
help: The button link value
And get it back with (assuming your data is stored on the site page):
<?php
$ctalinkurls = $site->ctalinkurl();
$ctalink = $site->url(). '/' .$site->index()->filterBy('autoid', '==', $ctalinkurls);
?>
<a href="<?= $ctalink ?>">