Project

General

Profile

Actions

Bug #46383

closed

levelmedia ignores sorting of media records

Added by Benjamin Robinson over 11 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
File Abstraction Layer (FAL)
Target version:
Start date:
2013-03-17
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
6.1
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

Precondition: a page with multiple FAL media records (images).

The sorting of media records is ignored. If the sorting is changed afterwards, it does not affect the order of the "FILES":

page.10 = COA
page.10{
  stdWrap.wrap = <ul>|</ul>
  stdWrap.required = 1
  10 = FILES
  10 { 
     references{
       data =  levelmedia:-1, slide
       treatIdAsReference = 1
     }
     renderObj = IMAGE
     renderObj {
       stdWrap.wrap = <li>|</li>
       stdWrap.required = 1
       file.import.data = file:current:originalUid // file:current:uid
    }
  }
}

This does work (but without "slide"):

page.10 = COA
page.10{
  stdWrap.wrap = <ul>|</ul>
  stdWrap.required = 1
  10 = FILES
  10 { 
     references{
       table = pages
       uid.data = page:uid
       fieldName = media
     }
     renderObj = IMAGE
     renderObj {
       stdWrap.wrap = <li>|</li>
       stdWrap.required = 1
       file.import.data = file:current:originalUid // file:current:uid
    }
  }
}


Related issues 5 (0 open5 closed)

Related to TYPO3 Core - Bug #43691: Media Image Import is brokenClosed2012-12-06

Actions
Related to TYPO3 Core - Epic #54260: WP: FAL Missing Issues / Features / APIClosed2012-04-222014-02-15

Actions
Related to TYPO3 Core - Bug #56150: Exception with "Hidden" sys_file_references when using levelmedia - RootlineUtility::enrichWithRelationFields ignores disable fieldClosed2014-02-20

Actions
Related to TYPO3 Core - Bug #54884: RootlineUtility does not consider foreign_sorting for relation fieldsClosedMarkus Klein2014-01-09

Actions
Related to TYPO3 Core - Bug #54884: RootlineUtility does not consider foreign_sorting for relation fieldsClosedMarkus Klein2014-01-09

Actions
Actions #1

Updated by Florian Schaeffer over 11 years ago

confirmed on TYPO3 6.1.1

When using (for debugging purposes only, the snippet just prints all available media images):

lib.navigationIcon = FILES
lib.navigationIcon {
  references {
    data =  levelmedia:-1, slide
  }
  renderObj = TEXT
  renderObj {
    data = file:current:publicUrl
    wrap = {image : '|', title : ' ', thumb : ' ', url : ''},
  }
}

I get another order of records as with

lib.navigationIcon = FILES
lib.navigationIcon {
  references {
    table = pages
    uid = 1
    fieldName = media
  }
  renderObj = TEXT
  renderObj {
    data = file:current:publicUrl
    wrap = {image : '|', title : ' ', thumb : ' ', url : ''},
  }
}

If I try to get the first record using levelmedia:-1, slide the files are not sorted correctly (following the SQL-statements I see sort by for all accesses to sys_file_reference).

To reproduce it just add more than one reesource to page, make sure that you slide up the tree to get the information and than change the order of thoses ressources. The frontend output won't change.

There is another bug #43691 which describes the same form cObject IMAGE so it is related to the levelmedia.

I debugged all SQL-queries and found, that when using levelmedia the sys_file_reference table is queried twice, the first time WIHTOUT sorting and the second time with sorting. Unfortunately the first query result is used for reading the file references for the media field.

So if I manually delete a media releation and add another one, the order is correct unless I change it by ordering the relations in the media field again.

Actions #2

Updated by Philipp Gampe over 11 years ago

  • Status changed from New to Accepted
  • Priority changed from Should have to Must have
Actions #3

Updated by Markus no-lastname-given about 11 years ago

A small workaround: If you use "sorting = sorting_foreign" it works for me. hth

lib.navigationIcon = FILES
lib.navigationIcon {
  sorting = sorting_foreign
  references {
    data =  levelmedia:-1, slide
  }
  renderObj = TEXT
  renderObj {
    data = file:current:publicUrl
    wrap = {image : '|', title : ' ', thumb : ' ', url : ''},
  }
}
Actions #4

Updated by Christian Reiter almost 11 years ago

I can confirm levelmedia ignores sorting of FAL references in 6.1.7

blabla= COA
blabla{
10 = IMAGE
10 {
file {
import.data = levelfield:1, media
treatIdAsReference = 1
import.listNum = 0
}
}
}

Levelfield is done through stdwrap and leads to the function getData in TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
This has a switch construct and for levelfield it just asks the rootline

switch ($type) {
...
case 'levelfield':
$keyP = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $key);
$nkey = $this->getKey($keyP[0], $GLOBALS['TSFE']->tmpl->rootLine);
$retVal = $this->rootLineValue($nkey, $keyP[1], strtolower($keyP[2]) == 'slide');
break;

In TYPO3\CMS\Core\Utility\RootlineUtility::enrichWithRelationFields

line 267

$rows = $this->databaseConnection->exec_SELECTgetRows('uid', $table, $whereClause);

  • No ORDER clause at all.
  • No enableFields respected
    • There is only $this->pageContext->deleteClause($table)
    • (this leads to an exception if a FAL reference is hidden!)

This part of RootlineUtility does query TCA but it doesn't ask for 'foreign_sortby' which would be right.

It does

foreach ($GLOBALS['TCA']['pages']['columns'] as $column => $configuration) {
...
$table = $configuration['foreign_table'];
$field = $configuration['foreign_field'];

Maybe just add

$sorting = $configuration['foreign_sortby'];

and use that (if not null/empty) for adding an orderByClause after the whereClause ?

Actions #5

Updated by Christian Reiter almost 11 years ago

This ought to be fixed in 6.2 with https://review.typo3.org/#/c/26727/ but that should be backported to 6.1

Actions #6

Updated by Markus Klein over 10 years ago

  • Status changed from Accepted to Resolved
  • Target version set to next-patchlevel
  • TYPO3 Version changed from 6.0 to 6.1
  • Is Regression set to No

This is fixed in 6.1 and 6.2 with #54884.

Will be released with 6.1.8

Actions #7

Updated by Fritz Welter over 10 years ago

Yes i confirm that as well (Typo3 6.2), and it even takes media from lower levels by mistake!

I have set media records in root page and subpage 2 and levelmedia takes them all

root
.
.--subpage1
.--subpage2

TS
#lib.sliderimages = COA
#lib.sliderimages {
  1. 1 = COA
  2. 1 {
  3. stdWrap.required=1
  4. stdWrap.outerWrap.cObject = TEXT
  5. stdWrap.outerWrap.cObject.value = '|',
  6. 2 = IMG_RESOURCE
  7. 2 {
  8. file {
  9. import.data = levelmedia: -1, slide
  10. treatIdAsReference = 1
  11. import.listNum = 0
  12. }
  13. }
  14. }
  15. 2 < .1
  16. 2.2.file.import.listNum = 1
  17. 3 < .1
  18. 3.2.file.import.listNum = 2
  19. 4 < .1
  20. 4.2.file.import.listNum = 3
  21. 5 < .1
  22. 5.2.file.import.listNum = 4
    #}
Actions #8

Updated by Sebastian Schmal over 10 years ago

mh, this ts dont work in T3 6.2 :(
the output is all the same image!

here the old code in T3 4.5.xx and higher

#IMAGE
          5 = IMAGE
          5 {
            wrap = |
            file {
              width = 705c
              height = 550c
              maxW = 705c
              maxH = 550c
              import {
                cObject = TEXT
                cObject {
                  cObject = TEXT
                  cObject {
                    value = fileadmin/templates/images/products/product1.jpg
                    override {
                      required = 1
                      data = levelmedia:-1, slide
                      wrap = uploads/media/|
                      listNum = 0
                    }
                  }
                  override {
                    required = 1
                    field = media
                    wrap = uploads/media/|
                    listNum = 0
                  }
                }
              }
            }
            altText.field = title
            titleText.field = title
            imageLinkWrap = 1
            imageLinkWrap {
              enable = 1
              typolink {
                target = _self
                parameter.field = uid
                title.cObject=TEXT
                title.cObject.field = nav_title // subtitle // title
              }
            }
          }

Actions #9

Updated by Sebastian Schmal over 10 years ago

here a new solution

5 = FILES
            5 {

              references {
                table = pages
                fieldName = media
              }
              renderObj = IMAGE
              renderObj {
                file {
                  width = 470c
                  height = 470c
                  maxW = 470c
                  maxH = 470c
                  import.data = file:current:publicUrl
                }
                #altText.data = file:current:title
                altText.field = title
                titleText.field = title

                layoutKey = default
                layout {
                  default {
                    element = <img src="###SRC###"  ###PARAMS### ###ALTPARAMS### ###BORDER### ###SELFCLOSINGTAGSLASH###>
                    source =
                  }
                  srcset {
                    element = <img src="###SRC###" srcset="###SOURCECOLLECTION###" ###PARAMS### ###ALTPARAMS### ###SELFCLOSINGTAGSLASH###>
                    source = |*|###SRC### ###SRCSETCANDIDATE###,|*|###SRC### ###SRCSETCANDIDATE###
                  }
                }

                sourceCollection {
                  small {
                    width = 200
                    srcsetCandidate = 600w
                    mediaQuery = (max-device-width: 600px)
                    dataKey = small
                  }
                  smallRetina {
                    if.directReturn = 1
                    width = 200
                    pixelDensity = 2
                    srcsetCandidate = 600w 2x
                    mediaQuery = (max-device-width: 600px) AND (min-resolution: 192dpi)
                    dataKey = smallRetina
                  }
                }
              }

            }

references {
table = pages
fieldName = media
}

this code is in 6.2 buggy!!
data = levelmedia:-1, slide

Actions #11

Updated by Benni Mack about 6 years ago

  • Status changed from Resolved to Closed
Actions #12

Updated by bitfire it services over 5 years ago

Probably the same as #54884 and #71973?

Actions #13

Updated by Benni Mack about 5 years ago

  • Related to Bug #54884: RootlineUtility does not consider foreign_sorting for relation fields added
Actions

Also available in: Atom PDF