Geta / geta-optimizely-categories

An alternative to Optimizely's default category functionality, where categories are instead stored as localizable IContent.
5 stars 10 forks source link

categories hierarchy handling & routing improvements #30

Open adnanzameer opened 6 months ago

adnanzameer commented 6 months ago

The current routing implementation is chaotic and does not function as intended.

To illustrate, let's consider a scenario where both global and site categories are enabled. In this case, accessing the /jobs URL path retrieves only one category from the site categories. This limitation arises due to the GetFirstBySegment function within the ICategoryContentLoader interface, which fails to aggregate adequately despite searching through descendants of the root. To resolve this, I introduced a new function named GetCategoriesBySegment. With an overload, this enhanced function searches for all categories associated with the 'jobs' segment globally or across sites and returns them via the IList currentCategories parameter in the controller.

The second issue pertains to path routing. According to the current documentation, paths like /siteassets/topics/sports/ and /globalassets/topics/global-category-1 should be functional, yet they are not. A trailing slash results in a 404 error. Furthermore, even if this were rectified, the CategoryPartialRouter's nextSegment.Next method would neglect the entire path, focusing solely on the segment for category retrieval. To address this, while maintaining the existing framework, I have introduced an option within CategoryOption called UseUrlPathForCategoryRetrieval. When enabled, this option ensures that category retrieval is based on the entire path rather than just the segment. the lookup path started with category root instead of siteassets or globalassets e.g /topics/sports/ /topics/global-category-1 if both root category for global and site-specific has topics as segment.

sonarcloud[bot] commented 6 months ago

Quality Gate Passed Quality Gate passed

Issues
2 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

adnanzameer commented 5 months ago

@brianweet, could you possibly take a look at this commit?