Use title in URL |
I'm not a professional, certainly are better solutions, but after much research I found the solution below, valid for CI3:
The model: function get_name() { $string = $this->uri->segment(3); $array=explode("8801",$string); $id = ($array[1] / 9); $this->db->where('id', $id); $query = $this->db->get('names'); return $query->result(); } Below, I'm associating names/albums: function get_albuns() { $string = $this->uri->segment(3); $array=explode("8801",$string); $idx = ($array[1] / 9); $sql = ("SELECT A.*, PA.* FROM albuns A, players_albuns PA WHERE PA.player_id=$idx AND PA.album_id = A.id ORDER BY ano, posodr, album_id ASC"); $query = $this->db->query($sql); return $query->result(); } The view: foreach ($name as $row); $playerid = $row->id; $name = $row->name; $linkname = (9 * $playerid); $str = convert_accented_characters( $name); $urln = $url_title = url_title($str, '-', TRUE); As my website is only local, I have great freedom in testing solutions, but of course, within my limitations, which are not few.Below, some results: echo "<a href='/allmedia/names/$url_title-wd8801$linkname'>$name</a>"; http://localhost/allmedia/names/ella-fit...wd88011395 echo "<a href='/music/album/$record-wd8803$linkrec'>$title</a>"; http://localhost/music/album/ella-fitzge...d880312705 |
Messages In This Thread |
Use title in URL - by omid_student - 02-19-2020, 02:04 AM
RE: Use title in URL - by wdeda - 02-19-2020, 07:19 AM
RE: Use title in URL - by John_Betong - 02-19-2020, 08:00 AM
RE: Use title in URL - by rmcdahal - 02-19-2020, 08:18 AM
RE: Use title in URL - by muuucho - 02-19-2020, 08:21 AM
RE: Use title in URL - by omid_student - 02-19-2020, 08:30 AM
RE: Use title in URL - by muuucho - 02-19-2020, 08:48 AM
RE: Use title in URL - by John_Betong - 02-19-2020, 09:12 AM
RE: Use title in URL - by omid_student - 02-25-2020, 12:19 AM
RE: Use title in URL - by John_Betong - 02-25-2020, 03:59 AM
RE: Use title in URL - by omid_student - 02-25-2020, 04:05 AM
RE: Use title in URL - by zahhar - 02-25-2020, 06:40 AM
RE: Use title in URL - by omid_student - 02-25-2020, 06:56 AM
RE: Use title in URL - by John_Betong - 02-25-2020, 07:55 AM
RE: Use title in URL - by omid_student - 02-25-2020, 08:40 AM
RE: Use title in URL - by advmihir123 - 02-28-2020, 04:21 AM
|