Bug #46383
levelmedia ignores sorting of media records
| Status: | Resolved | Start date: | 2013-03-17 | |
|---|---|---|---|---|
| Priority: | Must have | Due date: | ||
| Assigned To: | - | % Done: | 0% |
|
| Category: | File Abstraction Layer (FAL) | Spent time: | - | |
| Target version: | next-patchlevel | |||
| TYPO3 Version: | 6.1 | Is Regression: | No | |
| PHP Version: | Sprint Focus: | |||
| Complexity: |
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
History
#1 Updated by Florian Schaeffer about 2 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.
#2 Updated by Philipp Gampe about 2 years ago
- Status changed from New to Accepted
- Priority changed from Should have to Must have
#3 Updated by Markus no-lastname-given over 1 year 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 : ''},
}
}
#4 Updated by Christian Reiter over 1 year 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!)
- There is only
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 ?
#5 Updated by Christian Reiter over 1 year ago
This ought to be fixed in 6.2 with https://review.typo3.org/#/c/26727/ but that should be backported to 6.1
#6 Updated by Markus Klein over 1 year 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
#7 Updated by Fritz Welter over 1 year 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
#lib.sliderimages = COA
#lib.sliderimages {
- 1 = COA
- 1 {
- stdWrap.required=1
- stdWrap.outerWrap.cObject = TEXT
- stdWrap.outerWrap.cObject.value = '|',
- 2 = IMG_RESOURCE
- 2 {
- file {
- import.data = levelmedia: -1, slide
- treatIdAsReference = 1
- import.listNum = 0
- }
- }
- }
- 2 < .1
- 2.2.file.import.listNum = 1
- 3 < .1
- 3.2.file.import.listNum = 2
- 4 < .1
- 4.2.file.import.listNum = 3
- 5 < .1
- 5.2.file.import.listNum = 4
#}
#8 Updated by Sebastian Schmal over 1 year 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
}
}
}
#9 Updated by Sebastian Schmal over 1 year 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
#10 Updated by Sebastian Schmal about 1 year ago
here a new solution - T3 6.2 and slide:
[[http://blog.ingeniumdesign.de/2014/03/30/typo3-6-2-probleme-mit-ressourcen-media-auslesen/]]