【问题标题】:TYPO3 7.6 - tx_news 4.2.1 - no detail name in realurl?TYPO3 7.6 - tx_news 4.2.1 - realurl 中没有详细名称?
【发布时间】:2016-05-13 23:49:53
【问题描述】:

带有 tx_news 的 realurl 配置对我来说很好用,但我有一个问题。我不需要地址中的详细名称。

www.domain.org/news-list/news-detail/test-news-name-here/

现在我不需要“新闻详细信息”了。

这里是 PHP 代码 realurl.php

<?php


$TYPO3_CONF_VARS['FE']['addRootLineFields'].= ',tx_realurl_pathsegment';
$TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT'] = array( 
'pagePath' => array(
    'type' => 'user',
    'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
    'spaceCharacter' => '-',
    'languageGetVar' => 'L',
    'expireDays' => '3',
    'rootpage_id' => 1,
    'firstHitPathCache'=>1
),
'init' => array(
    'enableCHashCache' => TRUE,
    'enableCHashCache' => 1,
    'respectSimulateStaticURLs' => 0,
    'enableUrlDecodeCache' => 1,
    'enableUrlEncodeCache' => 1
),
'preVars' => array(
    array(
        'GETvar' => 'L',
        'valueMap' => array(
            //'de' => '0',
            //'en' => '1',
        ),
        'noMatch' => 'bypass',
    ),
    array(
        'GETvar' => 'no_cache',
        'valueMap' => array(
            'nc' => 1,
        ),
        'noMatch' => 'bypass',
    ),
),

'fileName' => array(
  'index' => array(
    'sitemap.xml' => array(
      'keyValues' => array(
        'type' => 1234,
      ),
    ),
  ),
),

'fixedPostVars' => array(
    'newsDetailConfiguration' => array(
        array(
            'GETvar' => 'tx_news_pi1[action]',
            'valueMap' => array(
                'detail' => '',
            ),
            'noMatch' => 'bypass',
        ),
        array(
            'GETvar' => 'tx_news_pi1[controller]',
            'valueMap' => array(
                'News' => '',
            ),
            'noMatch' => 'bypass',
        ),

        array(
            'GETvar' => 'tx_news_pi1[news]',
            'lookUpTable' => array(
                'table' => 'tx_news_domain_model_news',
                'id_field' => 'uid',
                'alias_field' => 'title',
                'addWhereClause' => ' AND NOT deleted',
                'useUniqueCache' => 1,
                'useUniqueCache_conf' => array(
                    'strtolower' => 1,
                    'spaceCharacter' => '-',
                ),
                'languageGetVar' => 'L',
                'languageExceptionUids' => '',
                'languageField' => 'sys_language_uid',
                'transOrigPointerField' => 'l10n_parent',
                'autoUpdate' => 1,
                'expireDays' => 180,
            ),
        ),
    ),

    '6' => 'newsDetailConfiguration',
    // For additional detail pages, add their uid as well
    //'13' => 'newsDetailConfiguration',
    //'22' => 'newsDetailConfiguration',
    //'4' => 'newsTagConfiguration',
    //'4' => 'newsCategoryConfiguration',

),
'postVarSets' => array(
    '_DEFAULT' => array(
        'controller' => array(
            array(
                'GETvar' => 'tx_news_pi1[action]',
                'noMatch' => 'bypass',
            ),
            array(
                'GETvar' => 'tx_news_pi1[controller]',
                'noMatch' => 'bypass',
            ),
        ),
        'stadt' => 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' => '-',
                    ),
                ),
            ),
        ),

        'tags' => array(
            array(
                'GETvar' => 'tx_news_pi1[overwriteDemand][tags]',
                'lookUpTable' => array (
                  'table' => 'tx_news_domain_model_tag',
                  'id_field' => 'uid',
                  'alias_field' => 'title',
                  'addWhereClause' => 'AND NOT deleted',
                  'useUniqueCache' => 1,
                  'useUniqueCache_conf' => array (
                    'strtolower' => 1,
                    'spaceCharacter' => '-',
                    ),
                ),
            ),
        ),

        'seite' => array(
            array(
                'GETvar' => 'tx_news_pi1[@widget_0][currentPage]',
            ),
        ),

        // news archive parameters
        'archiv' => array(
            array(
                'GETvar' => 'tx_news_pi1[overwriteDemand][year]',
            ),
            array(
                'GETvar' => 'tx_news_pi1[overwriteDemand][month]',
                'valueMap' => array(
                    'january' => '01',
                    'february' => '02',
                    'march' => '03',
                    'april' => '04',
                    'may' => '05',
                    'june' => '06',
                    'july' => '07',
                    'august' => '08',
                    'september' => '09',
                    'october' => '10',
                    'november' => '11',
                    'december' => '12',
                ),
            ),
        ),

    ),
),
// configure filenames for different pagetypes
'fileName' => array(
    'defaultToHTMLsuffixOnPrev' => 0,
),
);

?>

我需要那个打字稿吗?

plugin.tx_news {
    settings {
            link {
                    skipControllerAndAction = 1
            }
    }
}

在详细信息页面中,我检查了 realurl:

tx_realurl_exclude = 1

【问题讨论】:

  • 您确定您的问题与 realUrl 相关吗?您的新闻详情页面的 URL 是什么?
  • 我不知道是不是因为扩张消息。这也可能是 RealUrl 的问题。我已经在 deatil 网站上检查了这一点:“不要在 realurl 中显示”。 :(
  • 要获得更多帮助,了解您的新闻详情页面的 URL 是很重要的。如果您浏览到 /news-list/news-detail 会发生什么?
  • 采取这个:skipControllerAndAction = 0 这个消息是完美的。但新闻详细信息页面在 url 中。 skipControllerAndAction = 1 url is = www.domain.org/news-list/news-detail/detail/News/test-news-name-here/ 我认为realurl的配置有问题:tx_realurl_exclude

标签: typo3 typo3-7.6.x realurl tx-news


【解决方案1】:

您可以在同一页面上使用详细信息和列表插件。检查这个网址:https://forge.typo3.org/issues/50489

lib.news = USER
lib.news {
  userFunc = tx_extbase_core_bootstrap->run
  pluginName = Pi1
  extensionName = News
  controller = News
  settings =< plugin.tx_news.settings
  persistence =< plugin.tx_news.persistence
  view =< plugin.tx_news.view
}

lib.news_list< lib.news
lib.news_list {
  action = list
  switchableControllerActions.News.1 = list
}

lib.news_detail < lib.news
lib.news_detail {
  action = detail
  switchableControllerActions.News.1 = detail
}

[globalVar = GP:tx_news_pi1|news > 0]
  lib.field_news_single < lib.news_detail
[else]
  lib.field_news_list < lib.news_list
[end]

【讨论】:

  • 好的,谢谢,它适用于配置:同一页面上的列表和详细信息!
【解决方案2】:

回答:不能从说话的 URL 中排除当前(=最后一个)页面。

如果您对技术细节感兴趣,可以阅读 RealURL 的notes for integrators 了解更多信息。

【讨论】:

    【解决方案3】:

    只是对另一个解决方案的额外跟进:

    使用 TypoScript 条件在列表页动态呈现详细插件。

    [globalVar = GP:tx_news_pi1|news > 0]
      page.10 >
      page.10 < lib.news
    [global]
    

    当然,如果你需要渲染,你可以做更多花哨的东西,例如其他内容元素也是如此!

    [globalVar = GP:tx_news_pi1|news > 0]
      page.10 >
      page.10 = CONTENT
      page.10 {
        table = tt_content
        pidInList = <page ID of your detail page>
        orderBy = sorting
      }
    [global]   
    

    这将在列表页面上呈现详细页面的所有内容元素。

    【讨论】:

      【解决方案4】:

      如果您想在单独的页面上显示列表和单个视图,那么 https://github.com/sourcebroker/singleview 处的扩展程序 singleview 完全符合您的要求。

      此扩展使用 TYPO3 内置功能“显示来自 pid 的内容”,您可以在页面属性中找到该功能。在此扩展中,“显示来自 pid 的内容”字段的值是根据 $_GET 参数动态设置的。当 TYPO3 使用列表视图呈现页面时,ext:singleview 检查$_GET 参数是否具有单一视图请求。如果这是真的,那么它将“content_from_pid”字段设置为单个视图页面 uid 的值。这样,单视图页面及其内容和布局就会显示在列表视图页面上。

      对于 TYPO3 7.6,请使用 ext:singlenews 版本 1.3。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多