hellomoto Posted July 15, 2020 Share Posted July 15, 2020 For a repeater field called datetimes, when I just put "{datetimes.date} {datetimes.time}" the output for one with multiple entries is (paraphrased): 1stdate, 2nddate 1sttime, 2ndtime Is there a way of just specifying the 1st item's values in the repeater here? Link to comment Share on other sites More sharing options...
Robin S Posted July 15, 2020 Share Posted July 15, 2020 It's possible with a hook. In the "List of fields to display in the admin Page List" setting for the template, enter a string that identifies where the value from the first repeater will go, e.g. first_repeater_datetime. Don't put the normal { } delimiters around this string. Then add a hook like this in /site/ready.php: $wire->addHookAfter('ProcessPageListRender::getPageLabel', function(HookEvent $event) { $page = $event->arguments(0); $out = $event->return; if($page->template == 'your_template') { $datetime = ''; if($page->datetimes->count) { $first_item = $page->datetimes->first(); $datetime = $first_item->date . ' ' . $first_item->time; } $event->return = str_replace('first_repeater_datetime', $datetime, $out); } }); 5 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now