mirror of
https://github.com/flextype/flextype.git
synced 2025-08-09 06:36:52 +02:00
refactor(shortcodes): add additional check for entries_fetch shortcode
This commit is contained in:
@@ -13,6 +13,12 @@ use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
||||
if ($flextype->container('registry')->get('flextype.settings.shortcode.shortcodes.entries.enabled')) {
|
||||
// Shortcode: [entries_fetch id="entry-id" field="field-name" default="default-value"]
|
||||
$flextype->container('shortcode')->addHandler('entries_fetch', static function (ShortcodeInterface $s) use ($flextype) {
|
||||
return Arrays::get($flextype->container('entries')->fetch($s->getParameter('id')), $s->getParameter('field'), $s->getParameter('default'));
|
||||
if ($s->getParameter('id') != null &&
|
||||
$s->getParameter('field') != null &&
|
||||
$s->getParameter('default') != null) {
|
||||
return Arrays::get($flextype->container('entries')->fetch($s->getParameter('id')), $s->getParameter('field'), $s->getParameter('default'));
|
||||
}
|
||||
|
||||
return '';
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user