public function fullgallery() { if (isset($_POST['tags']) && !empty($_POST['tags'])) { $this->viewData['searh_tags'] = $_POST['tags']; $tags = explode(',', $_POST['tags']); } $imagesList = array(); $model = new GalleryModel(); $tagModel = new TagModel(); foreach ($tags as $tag) { $images = $model->getAllItemsByTagName(trim($tag)); $imagesList = array_merge($imagesList, $images); } $this->viewData['images'] = $imagesList; shuffle($this->viewData['images']); $this->viewData['tags'] = $tagModel->getAllItems(); echo $this->twig->render('gallery/gallery.html.twig', $this->viewData); }