Closed DynamiteGoesBoom closed 2 months ago
I've just realised that there's no actual documentation for the format required for Feed Me and icons, sorry about that!
Firstly, there's a bug with the integration, which is fixed for the next release. To get this early, run composer require verbb/icon-picker:"dev-craft-5 as 3.0.0"
.
Secondly, the value that you provide for the field will depend on what sort of icon your icon sets contain:
/solid/address-book.svg
- the relative path to the iconangle-right
- the name of the spritedropbox:61803
- the name of the glyph, plus the glyphIdfas fa-ad
- the CSS class name, handle or identifier (depends on what icon kit in use)[
{
"entry": "Icon Picker Feed Me",
"iconPickerFont": "dropbox:61803",
"iconPickerSprite": "angle-right",
"iconPickerSvg": "/brands/black-tie.svg",
"iconPickerFa5Free": "fas fa-ad"
}
]
Nice @engram-design! Thanks for this. I'll let you know if I run into any snags.
@engram-design I have this for my fieldMapping data for FeedMe:
"iconSelect": {
"field": "verbb\\iconpicker\\fields\\IconPickerField",
"node": "contentBlocks\/cta\/iconSelect\/value",
"default": ""
},
If you look at this feed under About > contentBlocks > cta you'll see the iconSelect and value
, but when I run the import that icon never gets added.
Am I missing something?
It's too bad the values changed so much. There's no easy way to migrate that content over now :/
You could use of the the Feed Me events to modify the data at each step, if that’s helpful? You could check against fa
and switch to far
or the corresponding family
@engram-design hmm never did that before...do you have any examples by chance?
Sure, you basically modify the feed content before it's used in importing. So it might look something like:
use craft\feedme\events\FeedProcessEvent;
use craft\feedme\services\Process;
use yii\base\Event;
Event::on(Process::class, Process::EVENT_BEFORE_PROCESS_FEED, function(FeedProcessEvent $event) {
if (is_array($event->feedData)) {
foreach ($event->feedData as $dataKey => $data) {
foreach ($data as $itemKey => $item) {
if (is_string($item) && str_starts_with($item, 'fa ')) {
$event->feedData[$dataKey][$itemKey] = str_replace('fa ', 'far ', $item);
}
}
}
}
});
Which is going to look for every item in your provided feed data, for every string that starts with fa
and replace that with far
. Of course you can get as complicated with this as you like, and I'm sure there's going to be some edge-cases to deal with. Depending on how many icons there are in your feed, it might be easier to just replace fa fa-thumbs-up
with far fa-thumbs-up
specifically for example.
Hope that helps?
@engram-design thanks as always. The icons aren't used a whole lot for most Fido projects but I'll keep this in mind for one project in particular.
Thanks again as always 🎉
Fixed in 3.0.1
Describe the bug
Hey Crawf,
I was hoping to pick your brain on this weird icon picker import issue. I asked Tommy at P&T about it already but he mentioned this may be more up your alley:
FeedMe is whining about the iconSelect not being an array or object, but isn’t the image below showing that?
My mapping looks like:
I’m not sure what else it’s looking for, do you have any thoughts?
Thanks again 🎉
Steps to reproduce
Craft CMS version
5.2.3
Plugin version
3.0
Multi-site?
No
Additional context
FeedMe is at version 6.1.0