getTitle(): string Get title of the directory
Returns:
string Title{% set directory = grav.get('flex').directory('contacts') %}
<h2>{{ directory.title|e }}</h2>
use Grav\Common\Grav;
use Grav\Framework\Flex\Interfaces\FlexDirectoryInterface;
/** @var FlexDirectoryInterface|null $directory */
$directory = Grav::instance()->get('flex')->getDirectory('contacts');
if ($directory) {
/** @var string $title */
$title = $directory->getTitle();
}
getDescription(): string Get description of directory
Returns:
string Description{% set directory = grav.get('flex').directory('contacts') %}
<p>{{ directory.description|e }}</p>
use Grav\Common\Grav;
use Grav\Framework\Flex\Interfaces\FlexDirectoryInterface;
/** @var FlexDirectoryInterface|null $directory */
$directory = Grav::instance()->get('flex')->getDirectory('contacts');
if ($directory) {
/** @var string $title */
$description = $directory->getDescription();
}
getObject( id ): Object | null Get an object, returns null if it was not found.
Parameters:
string)Returns:
object)null Object not found{% set directory = grav.get('flex').directory('contacts') %}
{% set contact = directory.object('ki2ts4cbivggmtlj') %}
{# Do something #}
{% if contact %}
{# Got Bruce Day #}
Email for {{ contact.first_name|e }} {{ contact.last_name|e }} is {{ contact.email|e }}
{% else %}
Oops, contact has been removed!
{% endif %}
use Grav\Common\Grav;
use Grav\Framework\Flex\Interfaces\FlexDirectoryInterface;
use Grav\Framework\Flex\Interfaces\FlexObjectInterface;
/** @var FlexDirectoryInterface|null $directory */
$directory = Grav::instance()->get('flex')->getDirectory('contacts');
if ($directory) {
/** @var FlexObjectInterface|null $object */
$object = $directory->getObject('ki2ts4cbivggmtlj');
if ($object) {
// Object exists, do something with it...
}
}
Check what you can do with Flex Object
getCollection(): Collection Get collection, returns null if it was not found.
Returns:
object){% set directory = grav.get('flex').directory('contacts') %}
{% set contacts = directory.collection() %}
{# Do something #}
<h2>Ten first contacts:</h2>
<ul>
{% for contact in contacts.filterBy({published: true}).limit(0, 10) %}
<li>{{ contact.first_name|e }} {{ contact.last_name|e }}</li>
{% endfor %}
</ul>
use Grav\Common\Grav;
use Grav\Framework\Flex\Interfaces\FlexDirectoryInterface;
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
/** @var FlexDirectoryInterface|null $directory */
$directory = Grav::instance()->get('flex')->getDirectory('contacts');
if ($directory) {
/** @var FlexCollectionInterface $collection */
$collection = $directory->getCollection();
// Do something with the collection...
}
Check what you can do with Flex Collection
Found errors? Think you can improve this documentation? Simply click the Edit link at the top of the page, and then the icon on Github to make your changes.
Powered by Grav + with by Trilby Media.