calling twig function through theme hook - #11
Conversation
anoziere
left a comment
There was a problem hiding this comment.
The renames and the theme-hook direction are fine, but there is a structural problem with moving <title> and og:type into the hook template.
head-top.html.twig is rendered by SEOneThemeHook as a standalone Twig render, outside the theme's inheritance chain. In flexy, around 25 templates override {% block title %} (404, faq, checkout, account, ...) and the product/content templates override {% block og_type %}. Once the layout stops declaring those blocks, every one of those overrides becomes dead code: the title falls back to the generic SEOnePageTitle() default on every non-catalog page, and og:type is hardcoded to website, including on product pages. Keeping title/og_type as overridable blocks in the layout (with the hook filling the defaults), or passing per-view values into the hook, would avoid the regression. This should be looked at together with thelia-templates/flexy#124.
Smaller things: the new SEOneThemeHook.php is missing declare(strict_types=1); head-top.html.twig assigns pageDesc/canonical to variables and then calls the same functions again a few lines below (double event dispatch); and the match in the hook has no default arm, so it only stays safe as long as supports() lists exactly the same strings.
Flexy commit