1. Go to this page and download the library: Download masugadesign/labreports library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
return [
'functions' => [
// The function name in this example is "bookDump"
'bookDump' => function ($entry) {
$author = $entry->getFieldValue('bookAuthor')->one();
$coverImage = $entry->getFieldValue('coverImage')->one();
return [
(int) $entry->id,
$entry->title,
$entry->postDate->format('F j, Y g:i a'),
($author ? $author->title : null),
($coverImage ? $coverImage->getUrl() : null),
$entry->getFieldValue('publisherName')
];
},
// The function name in this example is "assetDump"
'assetDump' => function ($asset) {
return [
(int) $asset->id,
$asset->filename,
(int) $asset->folderId,
(int) $asset->volumeId,
$asset->getFieldValue('customFieldHandle'),
$asset->getFieldValue('someOtherCustomField')
];
}
],
];
{# Twig #}
{% set value = entry.fieldHandle %}
// PHP
$value = $entry->getFieldValue('fieldHandle');