I want to load the paragraph id in theme preprocess.

function theme_preprocess_layout(&$variables) {
  $ID = $variables['content']['#paragraph'] ???; "contents - protected 'id' => array(1) = 68"
  $variables['attributes'] = new Drupal\Core\Template\Attribute($variables['attributes']);

It gives me the available method "load($id)" but I don't know how to implement this method.


Thanks to Beau for the help. The method is simply

$ID = $variables['content']['#paragraph']->id();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.