0
votes

My setup :

  • Typo3 6.2
  • Tx_news 3.2

One of my news (news UID = 948) is linked with one of my internal page (page UID = 99) and I would like to display on it all the news which are related (in this case only 1 news, the #948), inside a block with title of the news, thumbnail and link to read it. What I did with Typoscript :

  • Search in database all news with related link = 99. (Ok, I made it)
  • Get the UID of this news (948) (Ok, I made it)
  • Search into "sys_file_reference" table all the files UID related to this news (11681) (Ok, I made it)
  • Search into "sys_file" table the URL of picture from its UID (Impossible)

I got with success the UID of the sys_file I need ( = the picture of the news) but when I query on the "sys_file" table, no datas.

[... Typoscript ... ]

10 = TEXT
10 {

    field = uid_local
    wrap = UID of picture to display : |

}

20 = CONTENT
20 {

table = sys_file
select {

    selectFields = identifier
    pidInList = 0
    where =  sys_file.uid= ###my_marker###
    markers.my_marker.field = uid_local

}
renderObj = COA
renderObj {

    10 = TEXT
    10.field = identifier
    10.wrap = URL of the news picture : |

}
}

Output of this code is :

UID of picture to display : 11681

URL of the news picture :

I tried multiple alternative : change pid, inject the uid_local value manually ... no way to get my URL ( = identifier column in database).

Do you have any idea to solve my issue ? Thanks :)


EDIT : here is the last try I did and it works.

20 = FILES
20 {

    references.table = tx_news_domain_model_news
    references.uid = 948
    references.fieldName = fal_media

    renderObj = IMAGE
    renderObj.file.import.data = file:current:uid 
    renderObj.file.treatIdAsReference = 1 

}
1

1 Answers

1
votes

Don't do it by hand. Let TYPO3 help you:

20 = FILES 
20 { 
  references { 
    table = tx_news_domain_model_news
    // use the news record uid:
    uid.data = current:originalUid // current:uid
    // or is it fal_media ?
    fieldName = media
  } 
  renderObj = IMAGE 
  renderObj {
    file { 
      import.data = file:current:uid 
      treatIdAsReference = 1 
      width = 150c 
      height = 150c 
    } 
    altText.data = file:current:alternative
    titleText.data = file:current:title
    params = class="menu-img" 
    stdWrap.typolink.parameter.field = uid
  } 
  // maxItems = 1 
}

If you really want the url to the original file: use the IMG_RESOURCE object without resizing.