Skip to content

Commit 36fcf29

Browse files
committed
Fix 500 error when there is no parent.
1 parent 0c1f609 commit 36fcf29

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

user/themes/commerce/commerce.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function onPageInitialized()
3838
$metadata = $page->metadata();
3939
$summary = trim(strip_tags($page->summary(null, true)));
4040
$title = $page->title();
41-
41+
4242
$parentTitle = '';
4343
if ($page->parent()) {
4444
$parentTitle = $page->parent()->title();
@@ -47,7 +47,7 @@ public function onPageInitialized()
4747
$metadata_values = [
4848
'description' => trim(strip_tags($page->summary(155, true))),
4949
'article:publisher' => 'https://drupalcommerce.org/',
50-
'article:section' => $page->parent()->title(),
50+
'article:section' => $parentTitle,
5151
'og:sitename' => $config->get('site.title'),
5252
'og:title' => $title,
5353
'og:description' => $summary,
@@ -59,7 +59,7 @@ public function onPageInitialized()
5959
'twitter:site' => '@drupalcommerce',
6060
'twitter:author' => '@drupalcommerce',
6161
'twitter:label1' => 'Filed under',
62-
'twitter:data1' => $page->parent()->title(),
62+
'twitter:data1' => $parentTitle,
6363
];
6464
foreach ($metadata_values as $property => $value) {
6565
$metadata[$property]['name'] = $property;

0 commit comments

Comments
 (0)