Comments (3)
hast du auch ein Beispiel für rex_media_service::addMedia ?
Hier ein Beispiel um Uploadfiles von YForm zu syncen
$transferUploadFilesToMediaPool = static function(rex_media_category $mediaPoolCategory, rex_yform_manager_dataset $dataset) {
$uploadFiles = [
'file_1' => $dataset->getValue('file_1'),
'file_2' => $dataset->getValue('file_2'),
'file_3' => $dataset->getValue('file_3'),
'file_4' => $dataset->getValue('file_4'),
];
$moveFiles = [];
foreach ($uploadFiles as $uploadDir => $uploadFile) {
if ('' === $uploadFile) {
continue;
}
$path = rex_path::pluginData('yform', 'manager', 'upload/'.$dataset->getTableName().'/'.$uploadDir.'/'.$dataset->getValue('id').'_'.$uploadFile);
if (!file_exists($path)) {
continue;
}
$data = [];
$data['title'] = '';
$data['category_id'] = $mediaPoolCategory->getId();
$data['file'] = [
'name' => $uploadFile,
'path' => $path,
];
try {
$data = rex_media_service::addMedia($data, true);
$moveFiles[] = $data['filename'];
// addMedia verschiebt die Datei
// Original erhalten lassen
rex_file::copy(rex_path::media($data['filename']), $path);
} catch (rex_api_exception $e) {
throw new rex_functional_exception($e->getMessage());
}
}
$sql = rex_sql::factory();
$sql->setTable($dataset->getTableName());
$sql->setWhere('id = :id', ['id' => $dataset->getId()]);
$sql->setValue('files', implode(',', $moveFiles));
if ($sql->update()) {
return true;
}
return false;
};
from tricks.
huhu ... hast du auch ein Beispiel für rex_media_service::addMedia ?
rex_mediapool_syncFile ist mittlerweile deprecated
from tricks.
Sollte vielleicht lieber bei der REDAXO-Doku selbst stehen.
$data = [];
$data['title'] = '';
$data['category_id'] = $category_id;
$data['file'] = [
'name' => $filename,
'path' => $path,
];
rex_media_service::addMedia($data, true);
from tricks.
Related Issues (20)
- YForm Trick: Kontaktformular an richtige Ansprechpartner-E-Mail-Adresse, ohne E-Mail-Adresse offenzulegen HOT 1
- Neuer Trick: Artikel-Metadaten aus YForm-Tabelle per Ajax im Artikel hinzufügen HOT 14
- Neue Tipps & Tricks: Backups – Warum, wann und wie durchführen? HOT 8
- rex_list Datensatz duplizieren HOT 3
- Eigene Addons in der Backend Navigation oben plazieren HOT 7
- Modul Tipp: Repeater HOT 7
- Info: Sortierung Medienpool aufsteigend HOT 2
- Problem: Rendern nummerierter Listen mit Unterbrechung HOT 2
- UPDATE Tricks > Development > VSCode 1/2
- UPDATE Tricks > Development > VSCode 2/2 HOT 4
- REDAXO & XAMPP für Windows HOT 4
- Seitentitel und Metadaten anpassen mit Daten, die erst im Modul erzeugt werden HOT 1
- YForm: Datensatz klonen HOT 14
- Image URL bei Repeater ist defekt HOT 1
- VSCode und Redaxos PHP_CS_FIXER_CONFIG (auf dem Mac) HOT 1
- REDAXO Klassen ausserhalb REDAXO Kontext nutzen HOT 1
- Suchfunktion zeigt keine neuen Treffer HOT 5
- YForm Upload als Download bereitstellen
- `iwcc` entfernen
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tricks.