Return/render data from another template

I have two templates that are suppose to do the exact same thing, display the products. Is there a way for to use the same template (category.php) to prevent from having to repeat the same code for two templates which are the subcategory and category?

The reason I split them into two was because the category is only suppose to have subcategories and the subcategories are where all the products are stored. If there is a better solution to this please let me know. Any suggestions are welcome.

I tried doing this with a route but I was unable to.


One way of preventing to repeat code is to use snippets for the part that is identical in both templates. As regards the route, I must admit I’m not sure if you can overwrite the use of the intendedTemplate.

I am using snippets for repeating blocks such as the products but I would like to prevent from repeating all the logic from the controller and well, also the code from the template itself. But I guess I’ll just have to repeat code :disappointed_relieved:

So what exactly is different in the blueprints that makes you use two different templates?

I think the easiest solution would be to allow both category and product as child templates for the category blueprint. Most of the time the users will know anyway what they want to create, so I think using stricter rules is not worth it here.