Project

General

Profile

Actions

Bug #58615

closed

$data['media'] contains not allways the path to files in ContentObjectRenderer

Added by Kurt Gusbeth over 10 years ago. Updated over 10 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Frontend
Target version:
-
Start date:
2014-05-07
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
6.2
PHP Version:
5.3
Tags:
Complexity:
hard
Is Regression:
No
Sprint Focus:

Description

I have noticed that some people have problems with menues, that shows media-images:
http://blog.ingeniumdesign.de/2014/03/30/typo3-6-2-probleme-mit-ressourcen-media-auslesen/
http://www.typo3.net/forum/thematik/zeige/thema/117979/
This menu doesn´t work for Typo3 projects that were updated from Typo3 4.x to 6.2
(it works with fresh/new Typo3 projects and with older Typo3 versions):

lib.abstract = HMENU
lib.abstract {
  special = directory
  excludeDoktypes = 4
  1 = TMENU
  1 {
  wrap = |
    NO {
      allWrap = <div class="abstract_div">|</div>
      stdWrap.htmlSpecialChars = 0
      ATagTitle.field = subtitle // title
      ATagParams = class="abstract" 
      ATagTitle.field = subtitle // abstract 

      stdWrap.cObject = COA
      stdWrap.cObject {
        5 = IMAGE
        5.file {
          import.field = media
          import = uploads/media/ 
          import.listNum = 0
        }

        10 = TEXT
        10.field = title
        10.stdWrap.htmlSpecialChars = 1
        10.wrap = <div class="bold">|</div>

        20 = TEXT
        20.field = subtitle
        20.wrap = <div class="italic">|</div>
      }
    }
  }
}

The reason: $data['media'] contains here the integer value from the table "pages" and the field "media":
/typo3/systext/frontend/Classes/ContentObject/ContentObjectRenderer.php
public function start($data, $table = '')

Normally $data['media'] contains the path to all images of the media-field,
but in updated Typo3 projects $data['media'] contains the pure integer value.
That breaks the menue!

Actions #1

Updated by Markus Klein over 10 years ago

Can you please check if the FrontendContentAdapterService is enabled?

Install Tool -> All Configuration -> [FE][activateContentAdapter]

If you use old style TS you need the ContentAdapter to get the old values back in the old fields.
See also: https://github.com/TYPO3/TYPO3.CMS/blob/master/NEWS.md#frontend

Citing the NEWS.md:

If you manage to change your Typoscript to use the new format you should consider deactivating the Adapter with the Install Tool option [FE][activateContentAdapter] as the Adapter really slows down the system.

Actions #2

Updated by Markus Klein over 10 years ago

  • Status changed from New to Needs Feedback
Actions #3

Updated by Kurt Gusbeth over 10 years ago

OK, I have tested it.
If [FE][activateContentAdapter] = 1, then the TypoScript-Menu works fine.
If [FE][activateContentAdapter] = 0, then the menu shows allways the image with the ID from the field pages[media].

Is there any solution to create a TypoScript menu that works with [FE][activateContentAdapter] = 0 ???
I use the new css_styled_content, so I don´t know what you mean with old TypoScript here:

If you manage to change your Typoscript to use the new format you should consider deactivating the Adapter with the Install Tool option [FE][activateContentAdapter] as the Adapter really slows down the system.

Can you give me a hint?

Actions #4

Updated by Markus Klein over 10 years ago

Info: The media field does not contain the ID of the image in 6.x, but the number of images assigned to it. sys_file_reference is the real source for the images.

Full example: http://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Files/Index.html#cobj-files-examples

Actions #5

Updated by Kurt Gusbeth over 10 years ago

OK, the new menu looks like this and works with "[FE][activateContentAdapter] = 0". You can close this bug now, because there are some solutions...

# Abstract menu
lib.abstract = HMENU
lib.abstract {
  special = directory
  excludeDoktypes = 4
  1 = TMENU
  1 {
    NO {
      allWrap = <div class="abstract_div">|</div>
      stdWrap.htmlSpecialChars = 0
      ATagTitle.field = subtitle // title
      ATagParams = class="abstract" 
      ATagTitle.field = subtitle // abstract 

      stdWrap.cObject = COA
      stdWrap.cObject {

    #IMAGE
    5=FILES
    5{
      references{
        table=pages
        uid.field=tsfe:id
        fieldName=media
      }

      begin = 0
      maxItems = 1

      renderObj = IMAGE
      renderObj {
        file.import.data = file:current:publicUrl
        altText.data = file:current:title
      }
      stdWrap.wrap = <div class="abs_img">|</div>
    }

        10 = TEXT
        10.field = title
        10.stdWrap.htmlSpecialChars = 1
        10.wrap = <div class="bold">|</div>

        20 = TEXT
        20.field = subtitle
        20.wrap = <div class="italic">|</div>
      }
    }
  }
}

Actions #6

Updated by Markus Klein over 10 years ago

  • Status changed from Needs Feedback to Closed

Great.

Actions #7

Updated by Sven Tappert over 10 years ago

It's better to use file:current:uid in conjunction with treatIdAsReference. file:current:publicUrl will not render images with whitespaces in the filepath (since 6.2).

[...]

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

[...]
Actions

Also available in: Atom PDF