When visiting the page of a node revision (e.g. node/13/revisions/15/view) I am getting the error "The website encountered an unexpected error. Please try again later". Looking at dblog i can see the following error:
Error: Call to a member function id() on string in bootstrap_mint_preprocess_html() (line 15 of C:\UniServerZ\www\efka\themes\bootstrap_mint\bootstrap_mint.theme)
When using another theme (e.g. Bartik) there is no problem.
It seems that when visiting the revision page, the $node variable is a string and has the value of node id. I suppose that the problem has to do with the following value assignment in line 14 of bootstrap_mint.theme:
if ($node = \Drupal::request()->attributes->get('node')) {
Comments
Comment #2
Binu Varghese CreditAttribution: Binu Varghese commented@plessas,
Replace below code (line -14 in bootstrap_mint.theme file):
if ($node = \Drupal::request()->attributes->get('node')) {
$variables['attributes']['class'][] = 'page-node-' . $node->id();
}
with:
if (\Drupal::routeMatch()->getRouteName() == 'entity.node.canonical') {
$node = \Drupal::routeMatch()->getParameter('node');
$variables['attributes']['class'][] = 'page-nid-' . $node->id();
}
Shall incorporate in the next release.
Comment #3
Binu Varghese CreditAttribution: Binu Varghese commentedComment #4
Binu Varghese CreditAttribution: Binu Varghese commentedComment #5
plessas CreditAttribution: plessas commentedThank you for the reply. However, I am still getting the blank page with the error and I can see the following in the logs:
Error: Call to a member function getTitle() on string in bootstrap_mint_preprocess_breadcrumb() (line 190 of bootstrap_mint.theme)
Comment #6
Binu Varghese CreditAttribution: Binu Varghese commentedso.. apply the same logic there as well..
Comment #7
plessas CreditAttribution: plessas commentedYou are right.
It's OK now.
Comment #8
drupalfan2 CreditAttribution: drupalfan2 as a volunteer commentedThank you, this line
if (\Drupal::routeMatch()->getRouteName() == 'entity.node.canonical') {
helped me to solve my problem, too.
Comment #9
gourav.yadav CreditAttribution: gourav.yadav commentedThanks !
Comment #10
themaurice CreditAttribution: themaurice as a volunteer commentedThanks
if (\Drupal::routeMatch()->getRouteName() == 'entity.node.canonical') {
work for me too.