Open dijkr opened 1 year ago
I want the banner partial showing the banner for the category the product has a relation with. Right now, the banner only works when the route for a category is handled. This banner partial checks if the the second part of the url match something set at the CMS. Of course this second part is a name of a category -> {{ collection:categorien :slug:is="segment_2" }}
. Whenever a product is shown, the second part of the URL is a product.
Solved
return View::make('producten')
->layout('layout')
->with(['groupedProducts' => $groupedProducts,
'category' => $category,
'categorySlug' => $categorySlug,
]);
<a href="/{{ categorySlug }}/{{ slug }}">
Route::get('/{category:slug}/{product:slug}', [ProductController::class, 'showProduct']);
]php artisan route:clear
{{ partial:banner_cat }}
is loaded within two views. Meaning two different routes. Meaning the CMS will only display the CMS-banner when using/categorie/{category:slug}
this route at the moment. It won't respond to/product/{product:slug}
. Both routes need the same partial.The not so nice solution would be to create a new collection. And then create another Antlers-view that uses that collection. The partial doesn't need to change, but every product then need to set the category-banner. That is a lot of work and also doesn't make sense.
The best solution is to make the partial indepentent. I can see to obstacles:
The question is, should the category-data be indepentent from the back-end already, or should there be a solution with Antlers to catch this issue?
Check out https://github.com/dijkr/Copia/issues/16 to research the origin of this problem.