2014-12-02 74 views
0

我想創建一個使用realurl的URL爲tx_news創建所有標籤的列表。使用realurl URL創建新聞標籤的鏈接

RealURL配置爲標籤:

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

眼下名單獲得創建這樣:

newsTags = CONTENT 
    newsTags { 
     table = tx_news_domain_model_tag 
     select { 
     pidInList = 1,298 
     hidden = 0 
     deleted = 0 
     orderBy = title 
     } 
     orderBy = title 
     renderObj = COA 
     renderObj { 
     wrap = | 
     1 = LOAD_REGISTER 
     1 { 
      Counter.cObject = TEXT 
      Counter.cObject.data = register:Counter 
      Counter.cObject.wrap = |+1 
      Counter.prioriCalc = intval 
     } 
     2 = TEXT 
     2.insertData = 1 
     2.field = title 
     2.wrap = <li data-index="{register:Counter}"><a href="/labels/tag/|- 
     3 = TEXT 
     3.field = uid 
     3.wrap = |"> 

     5 = TEXT 
     5.field = title 
     5.wrap = |</a></li> 

     } 
     wrap = <ul>|</ul> 
    } 

忽略寄存器現在。 URL只是使用Title-UID生成的。有時標題中有一個點,然後URL不起作用。所以我很樂意使用URL realurl創建。這可能嗎?

回答

2

在您的解決方案中,您正嘗試手動構建鏈接。我強烈建議使用typolink來生成鏈接。如果RealURL可用並且在RealURL配置中配置了各自的GET參數,則Typolink會生成說出的URL。你只需要設置爲additionalParams標籤UID:

newsTags = CONTENT 
newsTags { 
    table = tx_news_domain_model_tag 
    select { 
     pidInList = 1,298 
     hidden = 0 
     deleted = 0 
     orderBy = title 
    } 
    orderBy = title 
    renderObj = COA 
    renderObj { 
     1 = LOAD_REGISTER 
     1 { 
      Counter.cObject = TEXT 
      Counter.cObject.data = register:Counter 
      Counter.cObject.wrap = |+1 
      Counter.prioriCalc = intval 
     } 
     2 = TEXT 
     2.field = title 
     2.insertData = 1 
     2.typolink { 
      # link to current page 
      parameter.current = 1 
      # the current tag 
      additionalParams = &tx_news_pi1[overwriteDemand][tags]={field:uid} 
      additionalParams.insertData = 1 
     } 
     2.wrap = <li data-index="{register:Counter}">|</li> 

    } 
    wrap = <ul>|</ul> 
} 

您可以只使用parameter = 999當然設定的目標頁面不同。

+0

哦,這很好,我不知道如果使用RealURL配置,typolink會提供說出的URL。另外,通過此代碼,Linktext是頁面的標題,而不是Newstag。只需添加'2.insertData = 1 \t 2.field = title' – nbar 2014-12-02 23:17:30

+0

我只是將後者添加到帖子中。感謝您完成。 TypoScript掌握了一切:-)。 – lorenz 2014-12-02 23:21:14