I have a standard portfolio structure projects>project>files
Files can be images, pdf or videos.
i have added a “author” text field to the files blueprint.
Now i wanna output a “files credits” on the project page. Let’s say the project have 3 photos, both of them have been made by “John Doe”, and the other one have been made by “Lucy Sky”. The user enter the ccorresponding author name for each file. I’d like to automatically display :
“Credit : John Doe, Lucy Sky”, without repeating “John Doe” two times…
If you just want to output all authors for all images without repeating anything, you can get an array of all unique authors of a given page’s images like this:
<?php
$authors = $page->images()->pluck('author', ',', true); // true will only get unique values
foreach($authors as $author) {
echo $author;
}
or
<?php
$authors = $page->images()->pluck('author', ',', true); // true will only get unique values
echo "Credit: " . implode(',', $authors);