verbb / vizy

A flexible visual editor for Craft CMS
Other
44 stars 8 forks source link

Help with crating a vizy module #269

Open anchovy opened 10 months ago

anchovy commented 10 months ago

Question

We've followed the documentation on https://verbb.io/craft-plugins/vizy/user-guides/creating-a-custom-node-from-scratch to create a new module.

We had to add use Craft; to fix the Class "modules\vizymodule\Craft" not found error thrown by the line Craft::setAlias('@vizy-module', __DIR__);

The pulgin works as expected until we try and run any craft command line commands, then we get the error:

./craft
Exception 'yii\base\InvalidArgumentException' with message 'Invalid path alias: @modules/vizymodule/controllers'

Any ideas how to get around this? I've tried adding a default controller in /controllers/DefaultController.php but this doesn't fix the issue.

Additional context

Craft edition & version | Craft Pro 4.5.9 Vizy | 2.1.12

engram-design commented 10 months ago

Just fixed up that missing Craft reference. And it depends on how your module is setup, there's lots of bootstrapping to do to get various things working like controllers which is why it might be useful to extend our base module as a starting point. Or, you can copy-paste from the previous link.

anchovy commented 10 months ago

Thanks for that @engram-design

I change the module to use Craft::setAlias('@modules/vizymodule', __DIR__); and in the Asset Bundle class to use $this->sourcePath = '@modules/vizymodule/assets'; and this seems to have cleared up the error running console comands.

engram-design commented 10 months ago

I’ll double check that, but you shouldn’t need to use @modules/vizymodule but glad that’s working.