diff options
author | Michael Francis <edude03@gmail.com> | 2011-07-15 18:15:57 -0400 |
---|---|---|
committer | Michael Francis <edude03@gmail.com> | 2011-07-15 18:15:57 -0400 |
commit | d6f1b4fb094acaa6b98843e746105aff3eb8735d (patch) | |
tree | f9635dfd824d03c7ebb61528d29f45f2d2d78cdb | |
parent | 657d270864c6f8f77d083fe4aa6ba636ecbbd372 (diff) | |
download | otakuhub-d6f1b4fb094acaa6b98843e746105aff3eb8735d.tar.xz |
Search across all content at once
-rw-r--r-- | controllers/SearchController.php | 12 | ||||
-rw-r--r-- | 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')); ?> -<?= $this->_render('element', 'search', compact('anime')) ?> +<?= var_dump($this->request()->controller); ?> -<?= $this->Paginator->paginate(array('separator' => '')) ?> +<h3> Anime </h3> +<hr> <table> <th>Title</th> <th>Date</th> <th>Type</th> -<?php foreach ($content as $item): ?> +<?php if(count($anime) > 0): ?> +<?php foreach ($anime as $item): ?> <tr> <td> <a href="/anime/view/<?= $item->special_id ?>"><?= $item->title ?></a> @@ -24,5 +26,69 @@ $this->styles($this->html->style('pagination')); </tr> <?php endforeach ?> </table> +<div style = "float:right"> +<?= $this->html->link("More", array('controller' => 'search', + 'action' => 'anime')); ?> +</div> +<?php else: ?> +<p> No results found</p> +<?php endif; ?> -<?= $this->Paginator->paginate(array('separator' => '')) ?> + +<h3> Manga </h3> +<hr> +<table> +<th>Title</th> +<th>Date</th> +<th>Type</th> +<?php if(count($manga) > 0): ?> +<?php foreach ($manga as $item): ?> + <tr> + <td> + <a href="/anime/view/<?= $item->special_id ?>"><?= $item->title ?></a> + </td> + <td> + <?= $item->aired ?> + </td> + <td> + <?= $item->view_type ?> + </td> + </tr> +<?php endforeach ?> +</table> +<div style = "float:right"> + <?= $this->html->link("More", array('controller' => 'search', + 'action' => 'anime')); ?> +</div> +<?php else: ?> +<p> No entries found </p> +<?php endif; ?> + +<h3> K Drama </h3> +<hr> +<table> +<th>Title</th> +<th>Date</th> +<th>Type</th> +<?php if(count($kdrama) > 0): ?> +<?php foreach ($kdrama as $item): ?> + <tr> + <td> + <a href="/anime/view/<?= $item->special_id ?>"><?= $item->title ?></a> + </td> + <td> + <?= $item->aired ?> + </td> + <td> + <?= $item->view_type ?> + </td> + </tr> +<?php endforeach ?> +</table> +<div style = "float:right"> + <?= $this->html->link("More", array('controller' => 'search', + 'action' => 'anime')); ?> +</div> +<?php else: ?> +<p> No Entries found </p> +<?php endif; ?>
\ No newline at end of file |