How can I include ID in URL using Slim Framework?

I’m new to using SLIM framework, I’m working on a project/platform that allows users to post their listings and take bookings from potential clients. But I want them to be able to share a link to their listing.

I have provided the relevant code below, that is used to display all these listings on a single page. When clicking on one of the listings, the information is pushed into a modal. I’m looking to generate a link for each listing that can be shared via email or message and accessed easily. How can I include the listing ID in the URL?

At the minute I’m stuck with:


My desired outcome is:



function listingInfo($id,$location){

// Detail View Specific







  method: "GET",

  url: "/listing_information/"+$id





// hide map if on mobile - link to external google maps site instead

 $('.listings-map').toggleClass('is-hidden', isMobile());
// set co-ord vals in hidden textbox
$('#listing-detail-directions-ll').val($location.toString().replace(/["'()]/g,'').replace(' ', ''));


}, 1000);


// to display all listings on a single page

$app->get('/listings', function ($request, $response, $args) {

$variables['title'] = 'Listings';

$variables['categories'] = $this->db->select('listing_categories','*');

return $this->view->render( $response, 'listings.html', $variables,);

I think this is what you are looking for.

Then you can generate the URL (assuming you have a route for it) with the path_for function.