Hello,
I try to have something working like @plagasul suggested here
Here my structure, on the first level of the site I’ve got a children agents with agent pages inside. I try to call those agents from a page production with a block with this blueprint called listeagents.yml
name: Liste d'agents
fields:
agent:
type: tags
layout: list
options: query
query: site.find('agents').children
but then I got the agent printed like: agents/agent1, agents/agent2
How to have juste the name of the agent and not the structure with the parent (agents) / and the name (agent1) ?
Thank you for your help.
Thank you @texnixe it works to catch all agents that have a page in the agents parent, but only those, it doesnt catch all the agents that are introduced int the articles page as type:tags that have a page and don’t have a page yet.
What I try to achieve is what @plagasul do with:
<?php $artists = $page->artists()->split(); /* Get artists from tag field as comma separated list */?>
<?php foreach ($artists as $artist): /* For each artist */?>
<?php if (page($artist)): /* If there is a page with that id */ ?>
<?= page($artist)->title()->html() ?> belongs to the gallery.
<?php else: ?>
<?= $artist ?> does not belong to the gallery.
<?php endif ?>
<?php endforeach ?>
Maybe I didn’t understand what is proposed on this page General question on the logic of a kirby website - #5 by KrsBee
I thought that artists with pages are pulled up from the artists page, and artists without pages are add directly in the current page as tag.
Sorry for my confusion.
Ah ok, I didn’t read the full context of the other threads. So this is about tags that can exist as children of the agents page, but it is also possible to add additional strings that are not pages.
So the equivalent of the above would be:
<?php $agents = $block->agents()->split(); /* Get artists from tag field as comma separated list */?>
<?php foreach ($agents as $agent): ?>
<?php if ($p = page($agent)): /* If there is a page with that id */ ?>
<?= $p->title()->html() . ' is a child of the agents page' ?>
<?php else: ?>
<?= $agent . ' is just a string' ?>
<?php endif ?>
<?php endforeach ?>