Bug #47322
closedImport Selection with TYPO3 Element Browser
100%
Description
When I use the "Import Selection" Feature of the TYPO3 Element Browser, I can't add more than one image at a time to a dataset. This occurs in all extensions I tested: tt_news, cal and own extensions. The TCA config of the "Browse For Files" Button is set to
'type' => 'group', 'internal_type' => 'file', 'uploadfolder' => 'uploads/tx_t1test', 'show_thumbs' => 1, 'size' => 15, 'maxitems' => '200', 'allowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], 'disallowed' => '',I tested with a clean TYPO3 6.04, 6.0.5-dev and 6.1-dev (Blank Package).
Files
Updated by Henrik Ziegenhain over 11 years ago
I think this is related to #45194
I noticed this so far only in EXT:imagecycle, because of this I posted it there.
Updated by Martin Borer over 11 years ago
can confirm this for all Typo3 6.* Versions! This is not a should have, it's a must have!
Updated by Marc Willmann over 11 years ago
- Target version changed from 6.0.5 to next-patchlevel
I also confirm this for all browsers and TYPO3 6.1.1 and 6.1.2. I suggest to raise the priority, this is not "should have"!
Updated by Nico Schieder about 11 years ago
Bump for next patch.
This is quite a big issue for all Users who need to select more than 10 files for a gallery or imageslider.
So it is sure a must-have.
Updated by Ernesto Baschny about 11 years ago
- Category set to File Abstraction Layer (FAL)
- Target version deleted (
next-patchlevel) - Is Regression set to No
Updated by Nico Schieder almost 11 years ago
- File browse_links.js browse_links.js added
Greetings!
I found the problem.
Error¶
The file typo3/js/browse_links.js has been altered in Typo3 6.* Version to use the new functions "BrowseLinks.File.insertElement()" and "BrowseLinks.File.insertElementMultiple()". The "insertElement()" function works, but the function "insertElementMultiple()" relays on another function "insertMultiple()" which you can find in one of the inline <script>-Tags.
The "insertMultiple()" however just returns false, so nothing is done.
Handle Function (browse_links.js)
handle: function(element) { var items = this.getItems(element); var selectedItems = []; if (items.length) { items.each(function(item) { if (item.checked && item.name) { selectedItems.push(item.name); } }); if (selectedItems.length == 1) { BrowseLinks.File.insertElement(selectedItems[0]); } else { BrowseLinks.File.insertElementMultiple(selectedItems); } BrowseLinks.focusOpenerAndClose(true); } },
insertElementMultiple Function (browse_links.js)
insertElementMultiple: function(list) { var uidList = []; list.each(function(index) { if (typeof BrowseLinks.elements[index] !== undefined) { var element = BrowseLinks.elements[index]; uidList.push(element.uid); } }); insertMultiple('sys_file', uidList); return true; }
insertMultiple() (script-Tag)
function insertMultiple(table, uid) { var type = ""; return false; }
Solution¶
My Solution is to alter the script so it only uses the working "insertElement()" function.
Now the Element Browser is importing the whole selection.
Just replace the old file with the new one and it should work!
handle: function(element) { var items = this.getItems(element); var selectedItems = []; if (items.length) { items.each(function(item) { if (item.checked && item.name) { BrowseLinks.File.insertElement(item.name); } }); BrowseLinks.focusOpenerAndClose(true); } },
Updated by Sebastian Fischer over 10 years ago
edited: Got the problem ignore my previous comment
Updated by Malte Riechmann over 10 years ago
Perfect. Thanks @Nico this worked for me.
Updated by Maik Hagenbruch almost 10 years ago
In my 6.2.9 installation this problem is almost there.
I did the solution from the last comment and it works. But is this problem not fixed in core until now?
Updated by Wouter Wolters over 9 years ago
- Status changed from New to Accepted
- TYPO3 Version changed from 6.0 to 6.2
This problem still applies in 6.2
Updated by J. Peter M. Schuler over 9 years ago
Problem still exists in 6.2.12; fix from @Nico still works in 6.2.12
Updated by Oskar Hasinski over 9 years ago
Hook Solution¶
ext_localconf.php
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['browseLinksHook'][] = 'Vendor\RegionalObject\Hook\BrowseLinksHook';
BrowseLinksHook.php
namespace Vendor\RegionalObject\Hook; use TYPO3\CMS\Core\ElementBrowser\ElementBrowserHookInterface; class BrowseLinksHook implements \TYPO3\CMS\Core\ElementBrowser\ElementBrowserHookInterface { /** * Initializes the hook object * * @param \TYPO3\CMS\Recordlist\Browser\ElementBrowser Parent browse_links object * @param array Additional parameters * @return void */ public function init($parentObject, $additionalParameters){ $resourcePathJavaScript = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('...') . 'Resources/...'; $parentObject->doc->loadJavascriptLib("{$resourcePathJavaScript}/browse_links.js"); } /** * Adds new items to the currently allowed ones and returns them * * @param array Currently allowed items * @return array Currently allowed items plus added items */ public function addAllowedItems($currentlyAllowedItems){ } /** * Modifies the menu definition and returns it * * @param array Menu definition * @return array Modified menu definition */ public function modifyMenuDefinition($menuDefinition){ } /** * Returns a new tab for the browse links wizard * * @param string Current link selector action * @return string A tab for the selected link action */ public function getTab($linkSelectorAction){ } /** * Checks the current URL and determines what to do * * @param string $href * @param string $siteUrl * @param array $info * @return array */ public function parseCurrentUrl($href, $siteUrl, $info){ } }
Then extend your insertMultiple with your custom JS.
Or just use the solution from @Nico.
Updated by Alex Borodinov over 9 years ago
Tell me pls, where this file should be allocated? (BrowseLinksHook.php)
Did it with my own extension, allowing to choose in backend, which js to use in import selection
Updated by Gernot Ploiner over 9 years ago
The bug still exists in TYPO3 6.2.12. Tested with Firefox and Chrome.
Updated by Markus Klein over 9 years ago
- Category changed from File Abstraction Layer (FAL) to Backend User Interface
- Priority changed from Should have to Must have
- Target version set to 6.2.13
- Sprint Focus set to Stabilization Sprint
Also present on current master branch.
Can be tested with ext:styleguide -> TCA -> GROUP -> GROUP: 5 internal_type=file, lots of file types allowed, show thumbs
Updated by Frank Nägler over 9 years ago
The ElementBrowser and specially the JS-Stuff need a complete refactoring.
Updated by Gerrit Code Review over 9 years ago
- Status changed from Accepted to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/39744
Updated by Gerrit Code Review over 9 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/39744
Updated by Gerrit Code Review over 9 years ago
Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/39744
Updated by Frank Nägler over 9 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset b6137d46ca4c18b5d8e19def7df53618cdef00f9.
Updated by Gerrit Code Review over 9 years ago
- Status changed from Resolved to Under Review
Patch set 1 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/39906
Updated by Frank Nägler over 9 years ago
- Status changed from Under Review to Resolved
Applied in changeset 027acbca6b7fdde07de9367aab64270a147b2e4d.
Updated by Riccardo De Contardi about 7 years ago
- Status changed from Resolved to Closed