Search code examples
typo3typo3-6.1.xrealurltx-news

Create links to news-tags with the realurl URL


I would like to create a list of all tags für the tx_news with the URL from realurl.

RealURL Config for tags:

'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' => '-'
                            )
                    )
                )
            ),

Right now the list get created this way:

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>
    }

ignore the register for now. The URL just get generated with Title-UID. And sometimes the title have a dot in it and then the URL dont work. So I would love to use the URL realurl creates. Is this possible?


Solution

  • In your solution, you're trying to build the link manually. I strongly suggest to use typolink for generating links. If RealURL is available and the respective GET parameters are configured in the RealURL configuration, Typolink generates speaking URLs. You just need to set additionalParamsfor the tag 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>
    }
    

    You can of course set the target page differently by just using parameter = 999.