Helpful node methods in Drupal 8

4
(1)

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:

197

How useful was this post?

Click on a star to rate it!

Average rating 4 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

Scroll to Top