Let's say you want to filter the list by a routing parameter, for example:
- http://localhost/acme/blog/posts/index/55 will display a list of logs for user_id 55
- http://localhost/acme/blog/posts/index/1 will display a list of logs for user_id 55
This can be acheived by adding this to your Index.php controller:
protected $userId;
public function index($userId = null)
{
// Store the routed parameter to use later
$this->userId = $userId;
// Call the ListController behavior standard functionality
$this->asExtension('ListController')->index();
}
public function listExtendQuery($query)
{
// Extend the list query to filter by the user id
if ($this->userId)
$query->where('user_id', $this->userId);
}
Last updated