/
[cms] Greedy template detection durning url parsing [5.2.2-B1]
[cms] Greedy template detection durning url parsing [5.2.2-B1]
The Front-End URL parsing code in In-Portal is build in a way to allow dealing with most complex URLs with ease. Typical URL can consist of these components:
- language (e.g. "english")
- theme (e.g. "advanced")
- anything before category (not used by default)
- category (e.g. "path/to/category")
- anything after category (e.g. "article-name")
- template ("path/to/template")
All parsing, except template happens from left to the right. The template is parsed from right to the left, because:
- if present, then it's always specified at the end of url
- most likely something else would come before template, e.g. category
This however is a problem when template is part of some other non-related category. For example:
URL | Category | Template | Issue Description | |
---|---|---|---|---|
1 | platform/login/register.html | Home > Platform | /platform/login/register.tpl | Category was partially detected from template, but it's not related to template in any way. |
2 | modern/search-results.html | Modern > Search Results | /search-results.tpl | Template was partially detected from category and prevented category design to be used. |
Solution
- in the "\kRewriteUrlProcessor::_parsePhysicalTemplate" method:
- compare current $vars['t'] (populated from category parsing) and new $vars['t'] (populated from template parsing), but prior to adding "/index"
- if detected category path is completely within detected template, then patch $vars['m_cat_id'] in a way to emulate fact, that category wasn't detected at all
- if detected template is completely within detected category path, then don't change $vars['t'] and return false