[英]TYPO3 Realurl Configuration Category Page
我有TYPO3 7.6.10。 我有tx_news。
我想按类别配置新闻页面。 我现在有:
'newsCategoryConfiguration' => array(
array(
'GETvar' => 'tx_news_pi1[overwriteDemand][categories]',
'lookUpTable' => array(
'table' => 'sys_category',
'id_field' => 'uid',
'alias_field' => 'title',
'addWhereClause' => ' AND NOT deleted',
'useUniqueCache' => 1,
'useUniqueCache_conf' => array(
'strtolower' => 1,
'spaceCharacter' => '-'
)
)
)
),
它有效,结果是:
/domain/page-With-List-Of-News-By-Category/Category
如果有子类别,则结果为:
/domain/-page-With-List-Of-News-By-Category/Category
我能得到:
/domain/page-With-List-Of-News-By-Category/Parent-Category/Sub-Category
也许有更快或更更好的方法。 但是,如果找不到,请尝试这种方式并使用userfunc自己构建它:
'useUniqueCache_conf' => [
'strtolower' => 1,
'spaceCharacter' => '-',
'encodeTitle_userProc' => 'My\Ext\Hooks\News\RealUrlCategories->buildCategoryPath'
];
和类像:
class RealUrlCategories {
function buildCategoryPath($parameters) {
$categoriesPath = '';
// find category rootline
// you can find the uid somewhere in $parameters, then iterate for parent categories and read db for the titles to build final string
...
// return generated string like "Parent-Category/Sub-Category"
return $categoriesPath;
}
}
问题是,realURL使用rawurlencode解析userFunc的结果。 因此, Parent-Category/Sub-Category
将转换为Parent-Category%252FSub-Category
。
您可以返回Parent-Category-Sub-Category
。 这也将存储在缓存中。
同样,您的UserFunc可以返回Parent-Category ~~~ Sub-Category,然后在$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['encodeSpURL_postProc']
钩子中用/
替换~~~但是~~~将存储在缓存中。
您还可以添加另一个参数,例如parent_category
,但是该可选参数在fixesPostVars
部分中不起作用,因为在此参数是必需的,因此,如果为空,则URL中会有一个双斜杠// category。
除了使用格式parent-category-sub-category之外,您还能找到其他解决方案吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.