Plugin unable to load template part 3

Hello Shopware community,

 

Another continuation of the same plugin, but this time for the backend.

My colleague made changes for the backend for our plugin but when he tries to load the backend component, he gets the following error:

What we try to do is have the backend component of our plugin load a templating file so we can check if the rest of our code actually works.

We think the problem lies with a naming convention but we aren’t sure about that. And if the problem isn’t with the naming convention, we have no clue what it could be. Here is a download link to the plugin.

Any help would be greatly appreciated :slight_smile:

Hello @dNovoNiels‍,

here we go again.  Sticking-out-tongue
“All good things go by three” - I’ll help you out one more time!

First of all: You’re using the doctrine Schema Tool for your install/update/uninstall-process.
While this is actually okay, I just want to let you know, that those can cause issues.
Doctrine creates the tables according to the default collation of the server, e.g. utf8_general_ci.
Shopware needs utf8_unicode_ci though, which then can and will result in errors, when your plugin has to join its custom tables with default tables.
In that case, you’d get an “Illegal mix of collations” error.

Now let’s get to your main issue:
First of all you messed up the event to register your controller.
The event says _Enlight_Controller_Dispatcher_ControllerPath_Backend_ Event _ while the controller is named  DnovoEvents.
Just adjust the event to Enlight_Controller_Dispatcher_ControllerPath_Backend_ DnovoEvents.

This way the template-directory for that controller gets added properly and the app.js is then properly recognized.

You’ll receive another error after that, saying you’ve got a syntax error in your custom backend model: Resources/views/backend/dnovo_events/model/event.js
To explain this error, you need to know, that Smarty is also used in our backend-templates.
Smarty parses everything that starts with an opening curly bracket ‘{’ and any character following, like ‘{a’ - this is already considered to be smarty-code.
In your model you use ‘{name’ - and that’s not a valid smarty call. Therefore you get an error.
What’s the solution here?
Just add a space between your curly opening brace and the first character, like this: ‘{ name’.

Alright, let’s try it again.
Oops, another error, this time saying:  Unable to load template snippet 'backend/dnovo_events/view/event.js’
This error actually comes from your file Resources/views/backend/dnovo_events/view/list/window.js.
You’re creating a listingStore here. But the application name you’re using here doesn’t fit: Shopware.apps.DnovoEvents.view.Event
Your store is not in the view-folder, it’s in the store-folder. Use this instead Shopware.apps.DnovoEvents. store.Event
ExtJS is dynamically loading template-files in the backend due to the application name, that’s why he tried to load a file that’s not existent. Have a look at the underlined parts above to see the connection between the App-Name you entered and the file Shopware tried to load. :slight_smile:

Afterwards I was able to successfully open your backend-module.

Do those information help you?
Did you understand them?

Just in case you didn’t, feel free to ask.

Patrick  Shopware

once again this worked like a charm :slight_smile: thanks [@Patrick Stahl](http://forum.shopware.com/profile/1869/Patrick Stahl “Patrick Stahl”)‍

shouldv’e seen the controller path issue myself, apparently we still have some problems when moving arround the files through git :confused:

and it’s too bad the documentation doesn’t say a word about the smarty parser on backend templates, at least not the documentation me and my colleague have read, which is pretty much everything in the developer guides

I’ve noticed a strange thing. I’m writing a plugin in 5.2 style with controller auto registration. At the beginning plugin worked ok, shows a simple window on backend. When I’ve added code responsible for writing data to database I got error snippet app.js not found.

The line of code that breaks plugin is $shop->registerResources(); 

Any idea, why is that?