function getViewer($action)
    {
        if ($this->parentController) {
            if (is_numeric($action)) {
                $action = 'view';
            }
            $viewer = $this->parentController->getViewer($action);
            $layoutTemplate = null;
            // action-specific template with template identifier, e.g. themes/mytheme/templates/Layout/MyModel_view.ss
            $layoutTemplate = SSViewer::getTemplateFileByType("{$this->recordType}_$action", 'Layout');

            // generic template with template identifier, e.g. themes/mytheme/templates/Layout/MyModel.ss
            if (!$layoutTemplate) {
                $layoutTemplate = SSViewer::getTemplateFileByType($this->recordType, 'Layout');
            }

            // fallback to controller classname, e.g. iwidb/templates/Layout/NestedModelController.ss
            $parentClass = static::class;
            while ($parentClass != Controller::class && !$layoutTemplate) {
                $layoutTemplate = SSViewer::getTemplateFileByType("{$parentClass}_$action", 'Layout');
                if (!$layoutTemplate) {
                    $layoutTemplate = SSViewer::getTemplateFileByType($parentClass, 'Layout');
                }
                $parentClass = get_parent_class($parentClass);
            }

            $viewer->setTemplateFile('Layout', $layoutTemplate);

            return $viewer;
        } else {
            return parent::getViewer($action);
        }
    }
function getViewer($action)
    {
        if ($this->parentController) {
            if (is_numeric($action)) {
                $action = 'view';
            }
            $viewer = $this->parentController->getViewer($action);
            $layoutTemplate = null;
            // action-specific template with template identifier, e.g. themes/mytheme/templates/Layout/MyModel_view.ss
            $layoutTemplate = SSViewer::getTemplateFileByType("{$this->recordType}_$action", 'Layout');

            // generic template with template identifier, e.g. themes/mytheme/templates/Layout/MyModel.ss
            if (!$layoutTemplate) {
                $layoutTemplate = SSViewer::getTemplateFileByType($this->recordType, 'Layout');
            }

            // fallback to controller classname, e.g. iwidb/templates/Layout/NestedModelController.ss
            $parentClass = static::class;
            while ($parentClass != Controller::class && !$layoutTemplate) {
                $layoutTemplate = SSViewer::getTemplateFileByType("{$parentClass}_$action", 'Layout');
                if (!$layoutTemplate) {
                    $layoutTemplate = SSViewer::getTemplateFileByType($parentClass, 'Layout');
                }
                $parentClass = get_parent_class($parentClass);
            }

            $viewer->setTemplateFile('Layout', $layoutTemplate);

            return $viewer;
        } else {
            return parent::getViewer($action);
        }
    }
function getViewer ( $ action ) { if ( $ this -> parentController ) { if ( is_numeric ( $ action ) ) { $ action = 'view' ; } $ viewer = $ this -> parentController -> getViewer ( $ action ) ; $ layoutTemplate = null ; // action-specific template with template identifier, e.g. themes/mytheme/templates/Layout/MyModel_view.ss $ layoutTemplate = SSViewer :: getTemplateFileByType ( "{$this->recordType}_$action" , 'Layout' ) ; // generic template with template identifier, e.g. themes/mytheme/templates/Layout/MyModel.ss if ( ! $ layoutTemplate ) { $ layoutTemplate = SSViewer :: getTemplateFileByType ( $ this -> recordType , 'Layout' ) ; } // fallback to controller classname, e.g. iwidb/templates/Layout/NestedModelController.ss $ parentClass = static :: class ; while ( $ parentClass != Controller :: class && ! $ layoutTemplate ) { $ layoutTemplate = SSViewer :: getTemplateFileByType ( "{$parentClass}_$action" , 'Layout' ) ; if ( ! $ layoutTemplate ) { $ layoutTemplate = SSViewer :: getTemplateFileByType ( $ parentClass , 'Layout' ) ; } $ parentClass = get_parent_class ( $ parentClass ) ; } $ viewer -> setTemplateFile ( 'Layout' , $ layoutTemplate ) ; return $ viewer ; } else { return parent :: getViewer ( $ action ) ; } }
If a parentcontroller exists, use its main template,
and mix in specific collectioncontroller subtemplates.
If a parentcontroller exists use its main template and mix in specific collectioncontroller subtemplates .