How to display the "meta_description" attribute of the parent page inside a DC-block?

Permalink Browser Info Environment
Hello,
I cannot display the "meta_description" attribute of the parent page inside a DC-Block. Only the attributes of the "view.php" are shown.
Is there a way to get the "meta_description" attribute by a link or something?

Thank You!
Mathias

Type: Discussion
Status: New
MathiasB
View Replies:
jordanlev replied on at Permalink Reply
jordanlev
To get attributes from the page that the block is on, you need to get the page with this code:
$c = Page::getCurrentPage();

Block templates work differently than theme templates, because in theme templates the Concrete5 system automatically sets up the $c variable for you -- but in block templates it does not, so you need to initialize $c yourself first.

Once you do that, then everything else should be the same:
$c->getAttribute('meta_description');

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.