From d6f1b4fb094acaa6b98843e746105aff3eb8735d Mon Sep 17 00:00:00 2001 From: Michael Francis Date: Fri, 15 Jul 2011 18:15:57 -0400 Subject: Search across all content at once --- controllers/SearchController.php | 12 +++++-- views/search/index.html.php | 74 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 80 insertions(+), 6 deletions(-) diff --git a/controllers/SearchController.php b/controllers/SearchController.php index 421efb6..a7b0cee 100644 --- a/controllers/SearchController.php +++ b/controllers/SearchController.php @@ -12,9 +12,17 @@ class SearchController extends \lithium\action\Controller { if (isset($this->request->query['q'])) { $q = '/' . $this->request->query['q'] . '/i'; - return Anime::search($q, $page, 'title'); + $conditions = array('title' => array('like' => $q)); + $limit = 10; + + + $anime = Anime::find('all', compact('conditions', 'limit')); + $manga = Manga::find('all', compact('conditions', 'limit')); + $kdrama = Kdrama::find('all', compact('conditions', 'limit')); + + return compact('anime', 'manga', 'kdrama'); + } - return $this->render(array('template' => 'index')); } public function anime($by = 'title') diff --git a/views/search/index.html.php b/views/search/index.html.php index 2afb320..f4f7259 100644 --- a/views/search/index.html.php +++ b/views/search/index.html.php @@ -2,15 +2,17 @@ $this->styles($this->html->style('pagination')); ?> -_render('element', 'search', compact('anime')) ?> +request()->controller); ?> -Paginator->paginate(array('separator' => '')) ?> +

Anime

+
- + 0): ?> +
Title Date Type
title ?> @@ -24,5 +26,69 @@ $this->styles($this->html->style('pagination'));
+
+html->link("More", array('controller' => 'search', + 'action' => 'anime')); ?> +
+ +

No results found

+ -Paginator->paginate(array('separator' => '')) ?> + +

Manga

+
+ + + + + 0): ?> + + + + + + + +
TitleDateType
+ title ?> + + aired ?> + + view_type ?> +
+
+ html->link("More", array('controller' => 'search', + 'action' => 'anime')); ?> +
+ +

No entries found

+ + +

K Drama

+
+ + + + + 0): ?> + + + + + + + +
TitleDateType
+ title ?> + + aired ?> + + view_type ?> +
+
+ html->link("More", array('controller' => 'search', + 'action' => 'anime')); ?> +
+ +

No Entries found

+ \ No newline at end of file -- cgit v1.2.3