verbb / icon-picker

A Craft CMS field to select SVG or font icons from a folder for use in your content.
Other
17 stars 8 forks source link

Unable to find source directory #8

Closed 1stevengrant closed 5 years ago

1stevengrant commented 5 years ago

I added a bunch of SVGs into an icons directory at the web root level

/Users/steven/Sites/craftsandbox/public/icons/

defined the config

<?php

return [
    '*' => [
        'iconSetsPath' => '/Users/steven/Sites/craftsandbox/public/icons/',
        'iconSetsUrl' => '/icons/',
    ]
];

but when I try to define the field, it tells me

Unable to locate SVG Icons source directory.
Please ensure the directory /Users/steven/Sites/craftsandbox/public/icons/ exists.

What am I missing?

engram-design commented 5 years ago

I've been using 'iconSetsPath' => CRAFT_BASE_PATH . '/public/icons/', locally (probably not a bad idea for multi-environment support), does that help at all?

Otherwise, what server setup and environment do you have? I'm going to assume that folder really, really exists 😁

1stevengrant commented 5 years ago

Yeah I tried that as well - same thing

I'm using Laravel Valet locally. Haven't attempted on an actual server yet.

Yeah, really really exists 😂

engram-design commented 5 years ago

I'll have a test locally with Valet just to make sure its not something specific.

1stevengrant commented 5 years ago

Just checking in on this @engram-design anything coming imminently to resolve? Thanks.

engram-design commented 5 years ago

Would you be able to give 1.0.5 a go?

1stevengrant commented 5 years ago

Same thing at this point.

knynkwl commented 5 years ago

I am getting the same errors with the documented configuration.

Craft CMS 3.1.22 Icon Picker 1.0.5

It's in trial mode when I get the error, I have not purchased it.

knynkwl commented 5 years ago

I figured out the problem and I think it's due to the documentation OR the plugin needs to be updated to work differently based onthe documentation.

@1stevengrant basically this plugin is mimicking the assets field, so if you point iconSetsPath to the folder that contains the /icons/, you will be able to pick that folder in the field.

For example, I put my /icon folder in /web/assets/ and set iconSetsPath to CRAFT_BASE_PATH . '/web/assets/',

Screen Shot 2019-04-16 at 12 08 04 PM

I think the main problem is the documentation though. It says to set iconSetsPath to CRAFT_BASE_PATH . '/icons/' which one would assume that the svg icons should be in /icons, when in-fact it's looking inside /icons for a folder of svg icons e.g. /icons/base/icon.svg.

engram-design commented 5 years ago

@knynkwl Firstly, the default folder behaviour should actually be CRAFT_BASE_PATH . '/web/icons/', which I have now changed in to. By default, it should point to a folder called icons in the root of your web root. This is called web by Craft so we'll follow suit.

CRAFT_BASE_PATH refers to the project root, not the web root, so that was incorrect on my part.

Of course, you can override this in your config setting, so it doesn't matter, but also added points to the docs about this, just so people can get 'up and running' quicker.

With regards to your second point, there was a bug I've fixed that wouldn't show single SVG icons that weren't in a folder, and required all icons to be placed in sub-folders. In your example, you should be using /web/assets/icons/ as your iconSetsPath.

Should be fixed in 1.0.6