Browse Source

Search across all content at once

Michael Francis 14 years ago
parent
commit
d6f1b4fb09
2 changed files with 80 additions and 6 deletions
  1. 10 2
      controllers/SearchController.php
  2. 70 4
      views/search/index.html.php

+ 10 - 2
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')

+ 70 - 4
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; ?>