enigmadigital / artvandelay Goto Github PK
View Code? Open in Web Editor NEWPlugin to allow importing and exporting fields in Craft CMS
License: MIT License
Plugin to allow importing and exporting fields in Craft CMS
License: MIT License
Hey!
Looking around the code there appears to be a command line option. I was just curious about how that works? I would love to be able to supply an object with a boilerplate for different types of sites that I can active in a build process.
Thanks!
This will involve modifying the package structure, moving files to top level.
I was just trying out your plug in and exported some fields from a site, then tried to import them via the import tab on the plugin and am getting the following error:
PHP warning
array_filter() expects parameter 1 to be array, null given
/Users/username/Documents/Sites/website.com/private_html/craft/app/fieldtypes/PositionSelectFieldType.php(61)
49 ));
50 }
51
52 /**
53 * @inheritDoc ISavableComponentType::prepSettings()
54 *
55 * @param array $settings
56 *
57 * @return array
58 */
59 public function prepSettings($settings)
60 {
61 $settings['options'] = array_keys(array_filter($settings['options']));
62 return $settings;
63 }
64
65 /**
66 * @inheritDoc IFieldType::getInputHtml()
67 *
68 * @param string $name
69 * @param mixed $value
70 *
71 * @return string
72 */
73 public function getInputHtml($name, $value)
Stack Trace
#0
– /Users/username/Documents/Sites/website.com/private_html/craft/app/etc/web/WebApp.php(681): CApplication->handleError(2, "array_filter() expects parameter 1 to be array, null given", "/Users/username/Documents/Sites/website.com/private_html/c...", 61)
676 if (version_compare(PHP_VERSION, '7', '>=') && $code === 2 && strpos($message, 'should be compatible with') !== false)
677 {
678 return;
679 }
680
681 parent::handleError($code, $message, $file, $line);
682 }
683
684 // Private Methods
685 // =========================================================================
686
#1
unknown(0): Craft\WebApp->handleError(2, "array_filter() expects parameter 1 to be array, null given", "/Users/username/Documents/Sites/website.com/private_html/c...", 61, ...)
#2
– /Users/username/Documents/Sites/website.com/private_html/craft/app/fieldtypes/PositionSelectFieldType.php(61): array_filter(null)
56 *
57 * @return array
58 */
59 public function prepSettings($settings)
60 {
61 $settings['options'] = array_keys(array_filter($settings['options']));
62 return $settings;
63 }
64
65 /**
66 * @inheritDoc IFieldType::getInputHtml()
#3
– /Users/username/Documents/Sites/website.com/private_html/craft/app/services/FieldsService.php(462): Craft\PositionSelectFieldType->prepSettings(null)
457
458 // Get the field type
459 $fieldType = $field->getFieldType();
460
461 // Give the field type a chance to prep the settings from post
462 $preppedSettings = $fieldType->prepSettings($field->settings);
463
464 // Set the prepped settings on the FieldRecord and the field type
465 $fieldRecord->settings = $preppedSettings;
466 $fieldType->setSettings($preppedSettings);
467
#4
+ /Users/username/Documents/Sites/website.com/private_html/craft/app/services/MatrixService.php(183): Craft\FieldsService->validateField(Craft\FieldModel)
#5
+ /Users/username/Documents/Sites/website.com/private_html/craft/app/services/MatrixService.php(234): Craft\MatrixService->validateBlockType(Craft\MatrixBlockTypeModel)
#6
+ /Users/username/Documents/Sites/website.com/private_html/craft/plugins/artvandelay/services/ArtVandelay_FieldsService.php(312): Craft\MatrixService->saveBlockType(Craft\MatrixBlockTypeModel)
#7
+ /Users/username/Documents/Sites/website.com/private_html/craft/plugins/artvandelay/services/ArtVandelay_ImportExportService.php(71): Craft\ArtVandelay_FieldsService->import(array("Default" => array("articleBody" => array("name" => "Article Body", "context" => "global", "instructions" => "", "translatable" => 0, ...), "backgroundColor" => array("name" => "Background Color", "context" => "global", "instructions" => "Hex value for alternate background color.", "translatable" => 0, ...), "body" => array("name" => "Body", "context" => "global", "instructions" => null, "translatable" => 1, ...), "featuredImage" => array("name" => "Featured Image", "context" => "global", "instructions" => "", "translatable" => 0, ...), ...)))
#8
+ /Users/username/Documents/Sites/website.com/private_html/craft/plugins/artvandelay/services/ArtVandelay_ImportExportService.php(14): Craft\ArtVandelay_ImportExportService->importFromExportedDataModel(Craft\ArtVandelay_ExportedDataModel)
#9
+ /Users/username/Documents/Sites/website.com/private_html/craft/plugins/artvandelay/controllers/ArtVandelayController.php(39): Craft\ArtVandelay_ImportExportService->importFromJson("{ "assets": [], "categories": [], "fields": { "Default": {...")
#10
+ /Users/username/Documents/Sites/website.com/private_html/craft/app/framework/web/actions/CInlineAction.php(49): Craft\ArtVandelayController->actionImportStep3()
#11
+ /Users/username/Documents/Sites/website.com/private_html/craft/app/framework/web/CController.php(308): CInlineAction->runWithParams(array("p" => "admin/artVandelay/import/1"))
#12
+ /Users/username/Documents/Sites/website.com/private_html/craft/app/framework/web/CController.php(286): CController->runAction(CInlineAction)
#13
+ /Users/username/Documents/Sites/website.com/private_html/craft/app/framework/web/CController.php(265): CController->runActionWithFilters(CInlineAction, array())
#14
+ /Users/username/Documents/Sites/website.com/private_html/craft/app/framework/web/CWebApplication.php(282): CController->run("importstep3")
#15
+ /Users/username/Documents/Sites/website.com/private_html/craft/app/etc/web/WebApp.php(811): CWebApplication->runController("artVandelay/importstep3")
#16
+ /Users/username/Documents/Sites/website.com/private_html/craft/app/etc/web/WebApp.php(281): Craft\WebApp->_processActionRequest()
#17
+ /Users/username/Documents/Sites/website.com/private_html/craft/app/framework/base/CApplication.php(184): Craft\WebApp->processRequest()
#18
+ /Users/username/Documents/Sites/website.com/private_html/craft/app/index.php(62): CApplication->run()
#19
+ /Users/username/Documents/Sites/website.com/public_html/index.php(19): require_once("/Users/username/Documents/Sites/website.com/private_html/c...")
2016-01-14 22:58:22 Apache/2.2.29 (Unix) mod_fastcgi/2.4.6 mod_wsgi/3.4 Python/2.7.8 PHP/5.5.18 mod_ssl/2.2.29 OpenSSL/0.9.8zg DAV/2 mod_perl/2.0.8 Perl/v5.20.0 / Craft 2.5.2759
I'm Japanese. so not well english, sorry.
I use "Art Vandelay 1.0.2",
Afte export the craft field , it appears as " null" .
This is an error log
"Use of undefined constant JSON_PRETTY_PRINT - assumed 'JSON_PRETTY_PRINT' (/[my host]/craft/plugins/artvandelay/models/ArtVandelay_ExportedDataModel.php:46)"
("my host" mean my server host.)
There 33 all the fields , of which matrix Fields There are 17.
Is this a bug ?
Table sections_i18n
is empty post-import.
When importing an entries field, the source setting for the entries field is lost. This means that the relationship to the correct section for the entries field has to be re-established manually after importing.
This appears to be because the source is stored in the JSON file by referring to the ID numbers of the sections the entries field relationship is set up for. However, this ID number is not guaranteed to be the same between sites.
Perhaps it would be better to store this relation using the section handle rather than it's ID. That way, if an entries field related to a section that was also being imported, the relationship could be properly re-established on import.
Relying on the section ID number in this instance seems to me to be very unreliable as it is highly unlikely that section ID numbers will be the same between different sites.
Would be nice if existing fields are being imported, the current content doesn't get deleted.
Tried to export/import a matrix field and noticed that I had a dropdown option in the matrix and its settings were not included in the JSON file.
Tried this with other items in the matrix and had the same issue
(Created a pull request to fix this)
Is there support for exporting the blocks inside a Matrix field? Currently, it only exports the Matrix field, not the block it contains as well.
{
"assets": [],
"categories": [],
"fields": {
"pageBody": {
"name": "Body",
"context": "global",
"instructions": "",
"translatable": 0,
"type": "Matrix",
"settings": {
"maxBlocks": null
}
}
},
"globals": [],
"sections": [],
"tags": []
}
Hey!
I love the name! Fun and memorable ;) I have been wanting something like this for some time.
Looks like your current import/export object is a literal map of the current craft object structure, which makes a lot of sense. I have a thought/idea/wish to offer...
What would be awesome is if the object itself was an easy to read/write schema. Less of a literal translation and more of a "common sense" mapping. That way you could just update it in an editor as it evolves.
Something like...
{
"Contact": {
"type": "Single",
"fields": {
"Phone": {
"type":"Text",
"options": ...
},
"Address": {
"type":"Rich Text",
"options": ...
}
},
"Event": {
"type": "Channel",
"fields": {
"Gallery": {
"type": "Matrix",
"fields": {
"Image Title": {
"type": "Text",
"options": ...
},
"Image": {
"type": "Asset",
"options":..
}
}
}
}
}
}
}
I don't mean to be presumptuous, but I thought I would check to see if you may be up to go this direction. I find that if you design the schema first, then you can use it as your roadmap. Who knows maybe Craft itself may be up for adopting something after a few iterations.
Hi,
I've been testing your plugin for a forthcoming project and I've bumped into a couple of issues.
When importing into Art Vandelay, pasting in a valid JSON object works as expected, except when I click the Import button on the /import/1 page, Craft fails with a "Bad Request The CSRF token could not be verified" error.
If I turn off CSRF protection, then the import continues and reports a success.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.