Modul ClassExtension should deliver a new template-file aswell

<%- if @topic_view.topic.tags.present? %>
<%= t 'js.tagging.tags' %>: <%- @topic_view.topic.tags.each do |t| %> <%= t %> <%- end %>
<% end %>

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 with a new one delivered with my module that extends PageController…
How to do that :wink:

thanks in advance


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)


namespace App\Web\Layout;
use PageController;

class MyPageController extends PageController {}

Then, the template you are looking for is

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

Hope this helps


hej, thank for youre reply
it does not work in my situation I guess.
If I would extend the i.e. PageController in that way, my class needs to be extended aswell, isn’t it?
MyPageController will only be taken if the class is ‘MyPage’. If so, the user has to change all the pagetypes in the CMS…
I would like to extend the PageController via a DataExtension so the classname does not have to be changed.

renderWith() sounds great but I have no idea how to use it,… which function do I have to overload/decorate to get renderWith take controll of the rendering?

You can use it like:
$this->renderWith([THE_STRING_OF_THE_TEMPLATENAME, 'Page']);

so it doesn’t have to be the same name as the page class name

Sure, but where to call it. In the doc you only find an example for an additional ajax-call

this is not working(ProductTest is reachable):

class OrderSale_ProductControllerExtension extends DataExtension{
	private static $allowed_actions = ["ProductTest"];
	public function ProductTest(){
		return "ProductTest";
	protected function init(){
		//parent::init(); //with or without...
		$this->renderWith(['OrderSale_Product', 'Page']);

I found onAfterInit as a hook for the ini(). It gets called but it does still not render with my alternative template-file

public function onAfterInit(){
	$this->getOwner()->renderWith(['OrderSale_Product', 'Page']);