Last active
January 10, 2020 18:48
-
-
Save lincoln-chawora/a5e2db23c1240f1ad267bcd998c4a8f5 to your computer and use it in GitHub Desktop.
How load a node in drupal 8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$route_name = \Drupal::routeMatch()->getRouteName(); | |
if ($route_name == 'entity.node.canonical') { | |
node = \Drupal::routeMatch()->getParameter('node'); | |
$node_type = $node->getType(); | |
$title = $node->getTitle(); | |
$visible = $node->isPublished(); | |
$node->setPromoted(TRUE); | |
$uid = $node->getOwnerId(); | |
// $author will be user object of the person who created the node. | |
$author = $node->getOwner(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment