diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Piwik.php b/module/VuFind/src/VuFind/View/Helper/Root/Piwik.php index b0594a005e35c3fbd57fcb2f50c3eeaad0907fcd..7ce3270573a6ec081ede17a9c601a20d0d449afc 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/Piwik.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/Piwik.php @@ -4,7 +4,7 @@ * * PHP version 7 * - * Copyright (C) The National Library of Finland 2014-2016. + * Copyright (C) The National Library of Finland 2014-2018. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, @@ -257,10 +257,11 @@ class Piwik extends \Zend\View\Helper\AbstractHelper protected function getSearchResults() { $viewModel = $this->getView()->plugin('view_model'); - if ('layout/lightbox' === $viewModel->getCurrent()->getTemplate()) { + $current = $viewModel->getCurrent(); + if (null === $current || 'layout/lightbox' === $current->getTemplate()) { return null; } - $children = $viewModel->getCurrent()->getChildren(); + $children = $current->getChildren(); if (isset($children[0])) { $template = $children[0]->getTemplate(); if (!strstr($template, '/home') && !strstr($template, 'facet-list')) { @@ -304,8 +305,16 @@ class Piwik extends \Zend\View\Helper\AbstractHelper */ protected function getRecordDriver() { - $viewModel = $this->getView()->plugin('view_model'); - $children = $viewModel->getCurrent()->getChildren(); + $view = $this->getView(); + $viewModel = $view->plugin('view_model'); + $current = $viewModel->getCurrent(); + if (null === $current) { + $driver = $view->vars('driver'); + if (is_a($driver, 'VuFind\RecordDriver\AbstractBase')) { + return $driver; + } + } + $children = $current->getChildren(); if (isset($children[0])) { $driver = $children[0]->getVariable('driver'); if (is_a($driver, 'VuFind\RecordDriver\AbstractBase')) {