【问题标题】:TYPO3 Realurl Configuration Category PageTYPO3 Realurl 配置类别页面
【发布时间】:2017-04-03 13:25:16
【问题描述】:

我有 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

【问题讨论】:

    标签: typo3 categories realurl


    【解决方案1】:

    也许有更快或更好的方法。但是如果你找不到,试试这个并以这种方式使用 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;
        }
    }
    

    【讨论】:

    • 完全没有效果,或者没有按预期工作?确保调用了 userfunc。清除自动加载缓存。
    • 完全没有效果。 realurl 的版本是: 2.0.14 。我清除所有缓存。
    • 检查 userfunc 是否被调用?
    • 放一些死('被称为!');里面,或者类似的东西。它应该中断脚本执行。如果什么都没发生,则不会调用它。确保命名空间和正确的脚本位置,以便自动加载可以找到它。
    • 我把 die('is called') 放在 'class RealUrlCategories' 之前,什么也没发生 :(
    【解决方案2】:

    问题是,realURL 使用 rawurlencode 解析 userFunc 的结果。所以Parent-Category/Sub-Category 将转换为Parent-Category%252FSub-Category

    1. 您可以返回Parent-Category-Sub-Category。这也将存储在缓存中。

    2. 您的 UserFunc 也可以返回 Parent-Category~~~Sub-Category 并且您在 $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['encodeSpURL_postProc'] 挂钩中将~~~替换为 /,但~~~将存储在缓存中.

    3. 您还可以添加另一个参数,例如parent_category,但此可选参数在fixesPostVars 部分中不起作用,因为此处参数是必需的,因此如果它为空,则您有一个双斜杠 / /category 在您的 URL 中。

    除了使用 parent-category-sub-category 格式之外,您能找到任何其他解决方案吗?

    【讨论】:

      猜你喜欢
      • 2018-12-11
      • 2015-04-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多