Modul ClassExtension should deliver a new template-file aswell

silverstripe-4
Tags: #<Tag:0x00007f10c8ab1a50>

#1

Hi I ve written a module that extends, let’s say, the PageController::class. To use the new functionality of my ExtendPage::class I need to overwrite the standard Page.ss with a new one delivered with my module that extends PageController…
How to do that :wink:

thanks in advance
fabi


#2

Hi

SS4 is all about the namespace, so if you need to create ss template files for the classes that you create, you need to follow the trails.

For example, this is your subclass (of PageController)

<?php

namespace App\Web\Layout;
use PageController;
...

class MyPageController extends PageController {}

Then, the template you are looking for is
PROJECT_ROOT/themes/THEME_NAME/templates/App/Web/Layout/Layout/MyPageController.ss


or, you can override renderWith() function in your class to add more flexibilities (e.g. if x happens, I would like to use y.ss instead)

Hope this helps

Chees
Leo