How link to URL of single news article via CONTENT object

1.8k views Asked by At

I am using the typoscript below to display news content via a CONTENT object. Everything is working great except the link doesn't go to the page of the article. Is there a way to tell the typolink that this is a news article and that it should use the cached CoolURI link for it?

Also, the additionalParameter I'm trying to append to the querystring isn't appearing.

    temp.MMtest = COA
temp.MMtest {

   10 = CONTENT
   10.table = tt_news
   #10.select.pidInList = 170  # Uid of the sysfolder where News records are stored
   10.select.pidInList = 18
   10.select.recursive = 10
   #10.select.where = uid=10 # Uid of an existing News record
   10.select.andWhere = deleted=0 AND hidden=0
   10.renderObj = COA
   10.renderObj {
     10 = TEXT
     10.field = title
     10.wrap = Title:&nbsp;|<br>
     10.typolink.parameter.field=uid
    typolink.parameter.dataWrap=|
    #typolink.additionalParams.insertData=1
    typolink.additionalParams.data=&my_extra_param=something
    #if.isTrue.field=header
   }
   10.renderObj.20=IMAGE
   10.renderObj.20{
          wrap=|
                            # show it only if inserted
          stdWrap.if.isTrue.field=image
          stdWrap.typolink.parameter.field=uid
          file.import=uploads/pics/
          file.import.field=image
          file.width=100
          file.height=100
   }
 }
1

There are 1 answers

2
maholtz On

I do not know, which parameters you need, so in short:

10.typolink {
  # you need a page to link too
  parameter = PAGE_ID_OF_SINGLE_VIEW

  # create an cacheable link, that does not depend on cooluri or realurl.
  useCacheHash = 1

  # add the additional params
  additionalParams.wrap = &tx_ttnews[uid]=|

  # data expects special commands
  # "&my_extra_param=something" cannot work on .data
  additionalParams.data = field:uid
}

If you need more then one additionalParams i would do it this way:

10.typolink {
  parameter = PAGE_ID_OF_SINGLE_VIEW
  useCacheHash = 1

  # Create an Content Object Array
  # so you can separat the different entries
  # the cObject will return &tx_ttnews[uid]=123&what[ever]=hardcodedvalue
  # additionalParams is filled with that string and added to the url
  additionalParams.cObject = COA
  additionalParams.cObject {
    10 = TEXT
    10.wrap = &tx_ttnews[uid]=|
    10.field = uid
    20 = TEXT
    20.wrap = &what[ever]=|
    20.value = hardcodedvalue
  }
}

You do not need

10.select.andWhere = deleted=0 AND hidden=0

this is added automatically by the CONTENT Object.

Read more about typolink about COA and about stdWrap and its property data and finally have a look at getText.