diff --git a/src/SplashingImages.php b/src/SplashingImages.php index 7cfdc89..fd58030 100644 --- a/src/SplashingImages.php +++ b/src/SplashingImages.php @@ -64,12 +64,6 @@ public function init(): void function(RegisterUrlRulesEvent $event) { $event->rules['splashing-images'] = 'splashing-images/default/index'; $event->rules['splashing-images/'] = 'splashing-images/default/index'; - $event->rules['splashing-images/curated'] = 'splashing-images/default/curated'; - $event->rules['splashing-images/curated/'] = 'splashing-images/default/curated'; - $event->rules['splashing-images/likes'] = 'splashing-images/default/likes'; - $event->rules['splashing-images/likes/'] = 'splashing-images/default/likes'; - $event->rules['splashing-images/collections'] = 'splashing-images/default/collections'; - $event->rules['splashing-images/collections/'] = 'splashing-images/default/collection'; $event->rules['splashing-images/find'] = 'splashing-images/default/find'; $event->rules['splashing-images/search'] = 'splashing-images/default/search'; $event->rules['splashing-images/search/'] = 'splashing-images/default/search'; diff --git a/src/controllers/DefaultController.php b/src/controllers/DefaultController.php index 899825c..17f67db 100644 --- a/src/controllers/DefaultController.php +++ b/src/controllers/DefaultController.php @@ -54,10 +54,10 @@ public function actionIndex($page = 1): Response * Redirect search form submit to correct results url * @throws \yii\web\BadRequestHttpException */ - public function actionFind(): Response + public function actionFind() { $query = Craft::$app->request->getRequiredBodyParam('query'); - return $this->redirect(UrlHelper::cpUrl('splashing-images/search' . '/' . $query . '/1')); + return $this->redirect(UrlHelper::cpUrl('splashing-images/search/1', ['search' => $query])); } /** @@ -66,15 +66,13 @@ public function actionFind(): Response * @param $page int * @return bool|Response */ - public function actionSearch(string $query, int $page): bool|Response + public function actionSearch(int $page) { + $query = $this->request->getRequiredQueryParam('search'); if (!$query) { return false; } $data = $this->unsplash->search($query, $page); - return $this->renderTemplate('splashing-images/_index', [ - 'query' => $query, - 'data' => $data, - ]); + return $this->renderTemplate('splashing-images/_search',['data' => $data]); } } diff --git a/src/templates/_search.twig b/src/templates/_search.twig new file mode 100644 index 0000000..7166616 --- /dev/null +++ b/src/templates/_search.twig @@ -0,0 +1,23 @@ +{# @var craft \craft\web\twig\variables\CraftVariable #} +{% extends "_layouts/cp" %} + +{% do view.registerAssetBundle("studioespresso\\splashingimages\\assetbundles\\SplashingImages\\SplashingImagesAsset") %} + +{% set plugin = craft.app.plugins.getPlugin('splashing-images') %} +{% set title = plugin.settings.pluginLabel ?? "Splashing Images" %} + +{% block tabs %} + {% include 'splashing-images/_includes/_tabs' with { search: true, selectedTab: 'search'} %} +{% endblock %} + +{% block actionButton %} + {% include "splashing-images/_includes/_search" %} +{% endblock %} + +{% block content %} + {% include "splashing-images/_includes/_images" %} + +{% endblock %}