diff options
author | raylu <raylu@mixpanel.com> | 2011-07-17 19:10:15 -0700 |
---|---|---|
committer | raylu <raylu@mixpanel.com> | 2011-07-17 19:10:15 -0700 |
commit | 2bd2b4951627ae78631cc292979c84fdff677ba0 (patch) | |
tree | 1d35ebe3de35275bf8a0d1dfbd9457bf52de1950 | |
parent | 467a1f8635ca93a48024fb80b4b44b4f979a2505 (diff) | |
download | otakuhub-2bd2b4951627ae78631cc292979c84fdff677ba0.tar.xz |
move 'related' html out of anime controller
-rw-r--r-- | controllers/AnimeController.php | 12 | ||||
-rw-r--r-- | views/anime/view.html.php | 8 |
2 files changed, 12 insertions, 8 deletions
diff --git a/controllers/AnimeController.php b/controllers/AnimeController.php index 3a40cee..4bdacac 100644 --- a/controllers/AnimeController.php +++ b/controllers/AnimeController.php @@ -19,15 +19,13 @@ class AnimeController extends \lithium\action\Controller { if (is_numeric($id)) { $data = Anime::search($id, null, 'special_id'); - $related = $data['anime']->related; - $str = ''; - for ($i = 0; $i < count($related); $i++) + $related = Array(); + foreach ($data['anime']->related as $rid) { - if ($i > 0) $str .= ', '; - $ra = Anime::search($related[$i], null, 'special_id'); - $str .= '<a href="' . $related[$i] . '">' . $ra['anime']->title . '</a>'; + $ra = Anime::search($rid, null, 'special_id'); + $related[$ra['anime']->title] = $rid; } - $data['related'] = $str; + $data['related'] = $related; return $data; } else diff --git a/views/anime/view.html.php b/views/anime/view.html.php index ce291c5..f51e863 100644 --- a/views/anime/view.html.php +++ b/views/anime/view.html.php @@ -48,7 +48,13 @@ for ($i = 0; $i < count($anime->genres); $i++) { } ?><?= $str ?><br> <b>Duration:</b> <?= $anime->episode_duration ?><br> <b>Rating:</b> <?= $anime->rated ?><br> -<b>Related:</b> <?= $related ?> +<b>Related:</b> <?php +$str = ''; +$keys = array_keys($related); +for ($i = 0; $i < count($keys); $i++) { + if ($i > 0) $str .= ','; + $str .= ' <a href="/anime/view/' . $related[$keys[$i]] . '">' . $keys[$i] . '</a>'; +} ?><?= $str ?> </p> </section> |