Hello
I have a flex-object for authors on my page, so I can use it as a directory. For this I have created a custom blueprint in user/blueprints/flex-objects/authors.yaml. In this file I have defined some fields for each author, like the name, avatar image, text for bio, and some tags.
I’ve created a twig template to display the authors with the following code (I’ve omitted some of the code to keep it short):
{# Flex authors directory #}
{% set flex = grav.get('flex_objects') %}
{% set authors = flex.directory('authors') %}
{% set collection = authors.getCollection() %}
{% for author in collection %}
<div class="col-2 col-6-medium col-12-large">
{% if author.avatar %}
<div class="align-center">
{# assign the uploaded file name to a variable #}
{% set avatar_data = author.avatar|first %}
{# append the filename to the intended source url #}
{% set avatar_url = url(avatar_data.path) %}
<img class="image fit" src="{{ avatar_url }}" title="" alt="">
</div>
{% endif %}
</div>
<div class="col-10 col-6-medium col-12-large">
Name: {{ author.authorname }} <br>
Biography: {{ author.biography }} <br>
Tags: {% for tag in author.tags %} {{ tag|raw }}{% if not loop.last %}, {% endif %}{% endfor %}
</div>
{% end for %}
Everything works correctly, and without problems (for the moment).
Now what I would like is to be able to choose an author for a page, just like when defining an author taxonomy, but with a select field that shows all the authors previously created in the flex-objects page.
How can I do it?
I have tried something like:
header.metadata.author:
type:select
label: Author
data-options@: '\Grav\Plugin\Admin\DataOptions::options'
data-options-default@: 'admin.flex-objects.authors'
validate:
required: true
but it hasn’t worked. It shows nothing.
Thank you for your help in advance.