I have an url like this: http://drupal.dev/en/news-events
It's not my current page url. How can I get the page title by using above url ?
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this communityI have an url like this: http://drupal.dev/en/news-events
It's not my current page url. How can I get the page title by using above url ?
From below code example you can get the page title as your requirement
$path = \Drupal::service('path.alias_manager')->getPathByAlias('/news-events');
if(preg_match('/node\/(\d+)/', $path, $matches)) {
$node = \Drupal\node\Entity\Node::load($matches[1]);
}
echo $node->getTitle();
Hope this helps. :)