So, I want to create a controller and template for the native woocommerce-taxonomy product_cat
.
I copied the template from the woocommerce plugin into my views-Folder and renamed it from taxonomy-product-cat.php
to taxonomy-product_cat.blade.php
(underscore because of the body class name taxonomy-product_cat-data
, but also tried it with dash). (Full path is resources/views/taxonomy-product_cat.blade.php
). I also changed its content to blade-Syntax:
@php wc_get_template( 'archive-product.php' ); @endphp
I then created a controller File TaxonomyProductCat.php
and named its method TaxonomyProductCat
:
namespace App\Controllers;
use Sober\Controller\Controller;
class TaxonomyProductCat extends Controller
{
public function sectionHeader()
...
Other names I tried:
- TaxonomyProduct_Cat
Nothing seems to work. Template is not loaded and of course controller doesn’t run either.
I use the “Query Monitor” Plugin to analyse the situation and it shows that index.php is used as template, even though it shows in the template hierarchy the different places where it looks for the correct template file. This list also (but not exclusively) shows the entry resources/views/taxonomy-product_cat.blade.php
but somehow does not load this template file.
Weird thing: If I rename the template to just taxonomy.blade.php
and controller file to Taxonomy.php
and method to Taxonomy
Everything works.
The body
-Element even has the necessary body-class taxonomy-product_cat-data
.
Could it be caused by the _
in the filename?
Please, every hint is much appreciated, I’m going nuts over this.
Thanks.
P.S.: Might be related to Controller for custom taxonomy not working but there’s no solution to the problem either.