diff --git a/flextype/shortcodes/EntriesShortcode.php b/flextype/shortcodes/EntriesShortcode.php new file mode 100644 index 00000000..0df8022e --- /dev/null +++ b/flextype/shortcodes/EntriesShortcode.php @@ -0,0 +1,22 @@ + + * @link http://romanenko.digital + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Flextype; + +use Thunder\Shortcode\ShortcodeFacade; +use Thunder\Shortcode\Shortcode\ShortcodeInterface; +use Flextype\Component\Arr\Arr; + +// Shortcode: [entries_fetch id="entry-id" field="field-name" default="default-value"] +$flextype['shortcodes']->addHandler('entries_fetch', function (ShortcodeInterface $s) use ($flextype) { + return Arr::get($flextype['entries']->fetch($s->getParameter('id')), $s->getParameter('field'), $s->getParameter('default')); +});