Code snippet that show you helpful node methods in Drupal 8.
// Get node type. $node_type = $node->getType(); // Get node title. $title = $node->getTitle(); // Get node status. $visible = $node->isPublished(); // Get node promoted status. $node->setPromoted(TRUE); // Get node uid. $uid = $node->getOwnerId(); // Get node user account. $author = $node->getOwner();
Similar Posts:
- how to Programmatically update an entity reference field in Drupal 8 & 9
- How to get view mode of node in Drupal 8 & 9
- How to get formatted node creation date in Drupal 8
- Drupal: Creating a Computed Entity Field
- How to display in twig node creation date yesterday / today format in drupal 8 / 9
704