For your approach Drupal has 'Contextual filters'. So you have to pass the url parameter and need to specify that which argument you want to catch. So if it's argument 0, 1 or 2 ( %1, %2 etc ) then that data will be collected and processed.
You can also assign your custom php code for the custom functionality. Please check with the screen shot. It's really pretty easy!
Let me know, this helps you!
Keep Drupalizing :)