protected static getCategoryPageUrl ( $pageCode, $category, $theme ) |
protected static function getCategoryPageUrl($pageCode, $category, $theme)
{
$page = CmsPage::loadCached($theme, $pageCode);
if (!$page) {
return;
}
$properties = $page->getComponentProperties('blogPosts');
if (!isset($properties['categoryFilter'])) {
return;
}
/*
* Extract the routing parameter name from the category filter
* eg: {{ :someRouteParam }}
*/
if (!preg_match('/^\\{\\{([^\\}]+)\\}\\}$/', $properties['categoryFilter'], $matches)) {
return;
}
$paramName = substr(trim($matches[1]), 1);
$url = CmsPage::url($page->getBaseFileName(), [$paramName => $category->slug]);
return $url;
}