I need to send a parameter by url to a function through an already configured route, let me explain, in the application/config/routes.php file I have my routes configured, I want to configure the following $route['leermensaje'] = 'citrabajadores/leermensaje';
one to send it from a view through href=""
but I don't know how to do it , when I try it, it sends me a 404 error. I attach the code of the view where I want to send the parameter...
salida = '<h6 class="dropdown-header"> Mensajes </h6>';
resp.map( (producto) => {
let text = producto.fecha_envio; const myArray = text.split("-"); let fecha = myArray[2] + "-" + myArray[1] + "-" + myArray[0];
/* En esta línea */ salida += '<a id="'+ producto.numero_web +'" href="<?= base_url();?>leermensaje/'+ producto.numero_web +'" class="dropdown-item d-flex align-items-center" >';
salida += '<div class="dropdown-list-image mr-3">';
salida += '<img class="rounded-circle" src="<?= base_url();?>assets/img/undraw_profile_2.svg" alt="...">';
salida += '<div class="status-indicator"></div>';
salida += '</div>';
salida += '<div>';
salida += '<div class="text-truncate">'+ producto.mensaje +'</div>';
salida += '<div class="small text-gray-500">'+ producto.nombre +' '+ producto.apellido +'</div>';
salida += '<div class="small text-gray-500">'+ fecha +' a las '+ producto.hora_envio +'</div>';
salida += '</div>';
salida += '</a>';
});
$('#listamensajes').html(salida);
To do what you say and receive by GET you must tell the Route that you are going to receive.
This way you can receive something like readmessage/1 and the back will receive 1 as a parameter.
I leave you the official documentation to guide you in the future:
https://codeigniter.com/userguide3/general/routing.html
EDIT:
To add more than 1 parameter is the same principle: