diff --git a/ci/application/controllers/Albums.php b/ci/application/controllers/Albums.php index 60da313..6864367 100644 --- a/ci/application/controllers/Albums.php +++ b/ci/application/controllers/Albums.php @@ -9,32 +9,30 @@ class Albums extends CI_Controller { } public function index(){ - $selectedGenre = '0'; // Valeur par défaut pour le genre si aucun n'est sélectionné - if ($_SERVER["REQUEST_METHOD"] == "POST") { - if(isset($_POST['Genre'])){ - $selectedGenre = $_POST['Genre']; - } - } - $albums = $this->model_music->getAlbums($selectedGenre); - $playlists = $this->model_music->getPlaylist(); + $genre = $this->model_music->getGenre(); $this->load->view('layout/header'); - $this->load->view('albums_list', ['albums' => $albums, 'playlists' => $playlists]); - $this->load->view('layout/footer'); - + $this->load->view('GenreFilter',['genre'=>$genre]); $selectedGenre = '0'; $search = ''; if ($_SERVER["REQUEST_METHOD"] == "POST") { - if(isset($_POST['Genre'])){ - $selectedGenre = $_POST['Genre']; - } + if(isset($_POST['Genre'])){ + $selectedGenre = $_POST['Genre']; + } } if ($_SERVER["REQUEST_METHOD"] == "POST") { if(isset($_POST['recherche'])){ $search = $_POST['recherche']; } } + $playlists = $this->model_music->getPlaylist(); + $albums = $this->model_music->searchAlbums($search, $selectedGenre); + $this->load->view('albums_list', ['albums' => $albums, 'playlists' => $playlists]); + $this->load->view('layout/footer'); } + + + public function view($album_id){ $songs = $this->model_music->getSongOfAlbum($album_id); if (empty($songs)) { diff --git a/ci/application/views/GenreFilter.php b/ci/application/views/GenreFilter.php index fc010cb..e6b64aa 100644 --- a/ci/application/views/GenreFilter.php +++ b/ci/application/views/GenreFilter.php @@ -1,12 +1,15 @@
"; + echo "
"; + echo "
"; echo ""; -echo""; + echo""; echo""; ?>