I am trying to print out a few links on a custom page template. I would like to use the title and url from each route.
I am trying to print out the title from the route.
I know I can get the url from:
$url = Url::fromRoute('route.name');
and I know I can get the current page title from
$request = \Drupal::request();
if ($route = $request->attributes->get(\Symfony\Cmf\Component\Routing\RouteObjectInterface::ROUTE_OBJECT)) {
$title = \Drupal::service('title_resolver')->getTitle($request, $route); }
but I am not sure how to request the title from a specific/ different route.
Thanks in advance.