getRandomBlog example

break;
                }

                $element->getData()->set('media', $media);
                break;

            case self::TYPE_ARTICLE_OR_BLOG:
                $isBlog = (bool) $element->getConfig()->get('blog_category');
                $categoryId = (int) $element->getConfig()->get('category_selection');

                if ($isBlog) {
                    $blog = $this->getRandomBlog($categoryId$context);
                    if (!$blog instanceof Blog) {
                        break;
                    }
                    $medias = $blog->getMedias();
                    $media = array_shift($medias);
                    if (!$media instanceof Media) {
                        break;
                    }

                    $element->getData()->set('blog', $blog);
                    $element->getData()->set('image', $media);
                    
Home | Imprint | This part of the site doesn't use cookies.