spicywebau / craft-odds-and-ends Goto Github PK
View Code? Open in Web Editor NEWA repo of useful tools for Craft CMS websites
License: MIT License
A repo of useful tools for Craft CMS websites
License: MIT License
Hi. While working on a PR we've discussed in #24, I stumbled upon a issue with the Width field.
I'm getting an exception every time I'm going to edit or create a new field under /admin/settings/fields
in the control panel:
yii\base\ErrorException:
Declaration of spicyweb\oddsandends\fields\Width::translatedOptions(bool $encode = false): array
must be compatible with
craft\fields\BaseOptionsField::translatedOptions(bool $encode = false, mixed $value = null, ?craft\base\ElementInterface $element = null): array
in /app/vendor/spicyweb/craft-odds-and-ends/src/fields/Width.php:206
Stack trace:
#0 [internal function]: yii\base\ErrorHandler->handleFatalError()
#1 {main}
(I added some line breaks to make it more readable)
Running:
Craft Pro 4.4.4
Odds & Ends 4.1.2
PHP: 8.2.3
Anyone porting this to 4
The fieldtypes Entries (Search) and Categories (Search) work great. It would be awesome to have the same functionality for Commerce Products as well.
Perhaps either use the cache so they get timed out or find a way to flag the files so that old ones (>1 day etc) can be purged on each request.
Hi there, any plans for Craft 3 support? Would you be open to a pull request (if you would like to continue maintaining things)?
Having issue with multi category select
https://prnt.sc/u04je7
Hi, I think this is a Tools issue and not SuperTable, but let me know if I'm wrong.
I'm using the Width field inside of a SuperTable field on a multi-site install. After I change the propagation method on the SuperTable field (since Craft 3.3), I can no longer save my entries and get the following error:
Error: Cannot use object of type supercool\tools\fields\data\WidthData as array in /Users/trav/Websites/louderthanten/vendor/supercool/tools/src/fields/data/WidthData.php:134
Stack trace:
#0 /Users/trav/Websites/louderthanten/vendor/supercool/tools/src/fields/Width.php(136): supercool\tools\fields\data\WidthData->setData(Array, Object(supercool\tools\fields\data\WidthData))
#1 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/base/Element.php(2270): supercool\tools\fields\Width->normalizeValue(Object(supercool\tools\fields\data\WidthData), Object(verbb\supertable\elements\SuperTableBlockElement))
#2 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/base/Element.php(896): craft\base\Element->normalizeFieldValue('grid')
#3 /Users/trav/Websites/louderthanten/vendor/yiisoft/yii2/validators/Validator.php(254): craft\base\Element->__get('grid')
#4 /Users/trav/Websites/louderthanten/vendor/yiisoft/yii2/base/Model.php(367): yii\validators\Validator->validateAttributes(Object(verbb\supertable\elements\SuperTableBlockElement), Array)
#5 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/services/Elements.php(1832): yii\base\Model->validate()
#6 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/services/Elements.php(2073): craft\services\Elements->_saveElementInternal(Object(verbb\supertable\elements\SuperTableBlockElement), true, false)
#7 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/services/Elements.php(1950): craft\services\Elements->_propagateElement(Object(verbb\supertable\elements\SuperTableBlockElement), false, Array)
#8 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/services/Elements.php(488): craft\services\Elements->_saveElementInternal(Object(verbb\supertable\elements\SuperTableBlockElement), false, true)
#9 /Users/trav/Websites/louderthanten/vendor/verbb/super-table/src/services/SuperTableService.php(771): craft\services\Elements->saveElement(Object(verbb\supertable\elements\SuperTableBlockElement), false)
#10 /Users/trav/Websites/louderthanten/vendor/verbb/super-table/src/fields/SuperTableField.php(857): verbb\supertable\services\SuperTableService->saveField(Object(verbb\supertable\fields\SuperTableField), Object(benf\neo\elements\Block))
#11 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/base/Element.php(2139): verbb\supertable\fields\SuperTableField->afterElementPropagate(Object(benf\neo\elements\Block), false)
#12 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/services/Elements.php(1957): craft\base\Element->afterPropagate(false)
#13 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/services/Elements.php(488): craft\services\Elements->_saveElementInternal(Object(benf\neo\elements\Block), false, true)
#14 /Users/trav/Websites/louderthanten/vendor/spicyweb/craft-neo/src/services/Fields.php(200): craft\services\Elements->saveElement(Object(benf\neo\elements\Block), false)
#15 /Users/trav/Websites/louderthanten/vendor/spicyweb/craft-neo/src/Field.php(687): benf\neo\services\Fields->saveValue(Object(benf\neo\Field), Object(craft\elements\Entry))
#16 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/base/Element.php(2139): benf\neo\Field->afterElementPropagate(Object(craft\elements\Entry), false)
#17 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/elements/Entry.php(1248): craft\base\Element->afterPropagate(false)
#18 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/services/Elements.php(1957): craft\elements\Entry->afterPropagate(false)
#19 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/services/Elements.php(488): craft\services\Elements->_saveElementInternal(Object(craft\elements\Entry), true, true)
#20 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/controllers/EntriesController.php(378): craft\services\Elements->saveElement(Object(craft\elements\Entry))
#21 [internal function]: craft\controllers\EntriesController->actionSaveEntry(false)
#22 /Users/trav/Websites/louderthanten/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#23 /Users/trav/Websites/louderthanten/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#24 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/web/Controller.php(187): yii\base\Controller->runAction('save-entry', Array)
#25 /Users/trav/Websites/louderthanten/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('save-entry', Array)
#26 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/web/Application.php(299): yii\base\Module->runAction('entries/save-en...', Array)
#27 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/web/Application.php(566): craft\web\Application->runAction('entries/save-en...', Array)
#28 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/web/Application.php(278): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#29 /Users/trav/Websites/louderthanten/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#30 /Users/trav/Websites/louderthanten/public/index.php(21): yii\base\Application->run()
#31 /Users/trav/.composer/vendor/laravel/valet/server.php(158): require('/Users/trav/Web...')
#32 {main}
Also getting this in the Queue log:
2019-08-28 15:14:57 - error - craft\queue\QueueLogBehavior::afterError
[323494] Resaving supertable blocks (attempt: 1) - Error (time: 1.721s): Cannot use object of type supercool\tools\fields\data\WidthData as array
2019-08-28 15:14:57 - error - Error
Error: Cannot use object of type supercool\tools\fields\data\WidthData as array in /vendor/supercool/tools/src/fields/data/WidthData.php:134
Tools version: 2.1.8
Craft version: 3.3.0.1
SuperTable version: 2.2.1
Multisite: yes
I created a 'Categories (search)' field and added it to an Entry Type. However, the field does not appear to be functional on the Edit Entry page. Investigating further I noticed an Uncaught ReferenceError: SupercoolTools is not defined
in the console, probably because the relevant JS file is not getting included in the page request.
(I’ve tried uninstalling and re-installing as suggested in #2, but that did not fix the issue.)
Hi there. I really like the "roll your own" widget thingy. I've not pushed it very far yet, but the first thing I found was that the title field wasn't working. The widget that appears just keeps using "Roll Your Own" as the title. I can't see what I might be doing wrong, so I assume this might be some kind of bug perhaps?
Cheers, Andrew
--
Not an issue, but instead a feature request.
It would be great if it were possible for the Entries (search) field to be able to return entries from a custom entry source of a section. At the moment you're able to set up the field and specify the entry source/section. But if I have a plugin which has registered some custom entry sources within one of the sections, I'd like the field to return only entries from within that custom entry source.
I attempted to do this by adding some JavaScript that manipulates the settings.sources property of the 'elementSelect' data for the rendered field, so it is an array with the handle of a custom entry source rather than the configured section handle. The actionSearchForElements() method correctly received the 'sources' parameter with my custom entry source in it. However, the PHP code that handles the retrieval of results does not account for custom entry sources. It only deals with the field's configured section when building up the element criteria model.
Not sure how much work this would be, but thought it would be worth asking.
Hi.
There is a (high) chance of users locking themselves out of the control panel when using Roll Your Own widgets.
If you click the "+ New widget"-button and select Roll Your Own, and then just click save (because you're curious or whatever), you then get an error saying "Couldn't save widget."
I guess the error is because the default suggestion for template (_dashboard
) does not exist.
This is error message is understandable, and is fine in itself.
The problem is that at this stage a row is actually saved to the database with the invalid reference to _dashboard
:
Example:
mysql> select * from widgets where type like '%RollYourOwn%';
+----+--------+------------------------------------------+-----------+---------+---------------------------------------------------+---------+---------------------+---------------------+--------------------------------------+
| id | userId | type | sortOrder | colspan | settings | enabled | dateCreated | dateUpdated | uid |
+----+--------+------------------------------------------+-----------+---------+---------------------------------------------------+---------+---------------------+---------------------+--------------------------------------+
| 8 | 2 | spicyweb\oddsandends\widgets\RollYourOwn | 5 | NULL | {"title":"Roll Your Own","template":"_dashboard"} | 1 | 2023-03-09 09:05:11 | 2023-03-09 09:05:11 | b00d5bae-67f6-496e-a9a6-99885cc1b5d8 |
+----+--------+------------------------------------------+-----------+---------+---------------------------------------------------+---------+---------------------+---------------------+--------------------------------------+
1 row in set (0.00 sec)
Every action you then try to do in the control panel results in a "Template not found"-error - stack:
craft\web\twig\TemplateLoaderException: Unable to find the template “_dashboard”. in /app/vendor/craftcms/cms/src/web/twig/TemplateLoader.php:108
Stack trace:
#0 /app/vendor/craftcms/cms/src/web/twig/TemplateLoader.php(69): craft\web\twig\TemplateLoader->_resolveTemplate('_dashboard')
#1 /app/vendor/twig/twig/src/Environment.php(261): craft\web\twig\TemplateLoader->getCacheKey('_dashboard')
#2 /app/vendor/twig/twig/src/Environment.php(309): Twig\Environment->getTemplateClass('_dashboard')
#3 /app/vendor/twig/twig/src/Environment.php(277): Twig\Environment->load('_dashboard')
#4 /app/vendor/craftcms/cms/src/web/View.php(451): Twig\Environment->render('_dashboard', Array)
#5 /app/vendor/spicyweb/craft-odds-and-ends/src/widgets/RollYourOwn.php(65): craft\web\View->renderTemplate('_dashboard')
#6 /app/vendor/craftcms/cms/src/controllers/DashboardController.php(466): spicyweb\oddsandends\widgets\RollYourOwn->getBodyHtml()
#7 /app/vendor/craftcms/cms/src/controllers/DashboardController.php(104): craft\controllers\DashboardController->_getWidgetInfo(Object(spicyweb\oddsandends\widgets\RollYourOwn))
#8 [internal function]: craft\controllers\DashboardController->actionIndex()
#9 /app/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#10 /app/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#11 /app/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('index', Array)
#12 /app/vendor/craftcms/cms/src/web/Application.php(301): yii\base\Module->runAction('dashboard/index', Array)
#13 /app/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction('dashboard/index', Array)
#14 /app/vendor/craftcms/cms/src/web/Application.php(286): yii\web\Application->handleRequest(Object(craft\web\Request))
#15 /app/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#16 /app/web/index.php(15): yii\base\Application->run()
#17 {main}
And now you're stuck without any way to disable the widget yourself.
You'll need someone with direct access to the database to delete the row.
PHP 8.2.3
Craft Pro 4.3.10
MySQL 5.7.41
Odds & Ends 4.1.1
One more piece that might be relevant - in our general config we've overridden the default extension for Twig:
->defaultTemplateExtensions(['html.twig'])
We're actually using Odds & Ends just for the field type "Categories (multiple groups)".
Could a (partial) solution be to make which parts of this plugin to activate be configurable?
Reading a config file in Tools::init()
or something? With all options enabled as default to be backwards compatible.
Are you open to PRs?
When you have two or more dropdown boxes in one matrix field, of the type of Dropdown (other), an issue occurs when clicking on the dropdowns.
If you click on a dropdown that is not the first in the field, it opens the textfield for the first dropdown.
Watch this video: https://sendvid.com/6jk5rrr1
Thanks
e.g. disabled Categories and Entries
Hi, Any chance of getting a disabled 'Users' field option?
Thanks in advance.
PHP 8.2.4
Craft Pro 4.4.5
Yii 2.0.47
Declaration of spicyweb\oddsandends\fields\Width::translatedOptions(bool $encode = false): array must be compatible with craft\fields\BaseOptionsField::translatedOptions(bool $encode = false, mixed $value = null, ?craft\base\ElementInterface $element = null): array
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.