Jump to content
  • 0

My first Plugin throws an error

Go to solution Solved by Tadso,


Hi everyone,


I try to make a plugin to show some usage statistics for the client.

I created a plugin "usage", added the action for the navigation, set up language files etc., everything that is required per the documentation.

I created a controller file "plugins/usage/controller/client_main.php" and the view "/plugins/usage/views/default/client_main.pdt".

Once i press the new navigation item "your usage" that leads to "client/plugin/usage/client_main/index/" i get a blank page and in the error log ther is the follwing error:

[2020-06-16 12:27:39] general.ERROR: Exception: Files does not exist: /mypath/blesta/plugins/usage/views/client/bootstrap/client_main_myinfo.pdt in /mypath/blesta/vendors/minphp/bridge/src/Lib/View.php:158 Stack trace: #0 /mypath/blesta/vendors/minphp/bridge/src/Lib/Controller.php(222): View->fetch('mypath...', NULL) #1 /mypath/blesta/app/controllers/client_main.php(717): Controller->partial('client_main_myi...', Array) #2 mypath/blesta/app/controllers/client_main.php(50): ClientMain->setMyInfo() #3 mypath/blesta/vendors/minphp/bridge/src/Lib/Dispatcher.php(133): ClientMain->preAction() #4 /mypath/blesta/index.php(21): Dispatcher::dispatch('blesta/...') #5 {main} 


why is it looking for the "client_main_myinfo.pdt" in my plugin folder, it is in the app-folder?

Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0
  • Solution

Problem found: typo in folder name "controllers".

Also, for a new page in the client the combination of:



$this->view->view = 'default';

renders the new page inside the client portal.


Consider this topic as solved.




Link to post
Share on other sites
  • 0

The error seems to indicate that you called $this->partial('client_main_myinfo', ...).  So it is expected that it is looking for client_main_myinfo.pdt.  You are asking why it looks in the plugin dir instead of the default app dir?  Well likely your plugin has modified the view path in order to fetch your client_main.pdt file.  That being said, $this->partial() has a 3rd parameter for the directory to search in which you can you to override the view path. You might try using APPDIR for that parameter

Link to post
Share on other sites
  • 0

All I did was following the documentation:

https://docs.blesta.com/display/dev/Creating+a+Plugin except managing



so my plugin does not contain any custom logic, just the bare minimum. it has one action for the navigation, one controller and one view.

I tried to find what i was missing by reading the code from the other plugins, but couldn't figure it out.

Where can I find more info about:




If there is a documatation about the renderer used i might be able to figure out what i am missing.

I tried to set $this->structure->setDefaultView(APPDIR); in preAction() of the UsageController. No matter what i change or copy from other plugins, I always get the same error.

I think the "views/client/bootstrap/client_main_myinfo.pdt " is part of the main bootstrap template and gets loaded anyway, i just don't get why the other plugins like "order" have no issue with this.


Link to post
Share on other sites
  • 0

Short answer: Use $this->partial('client_main_myinfo', $vars, APPDIR);

Longer answer:

The portion in the example code:

        // Override default view directory
        $this->view->view = "default";
        $this->structure->view = "default";

That is what I'm speaking of.

Unfortunately there isn't really any documentation on these classes other than the code itself.  $this->partial() is a method defined here https://github.com/phillipsdata/minphp-bridge/blob/master/src/Lib/Controller.php, or in the blesta code at vendors/minphp/bridge/src/Controller.php. That is also where $this->structure and $this->view are set.  Both of those properties instantiate the View class https://github.com/phillipsdata/minphp-bridge/blob/master/src/Lib/View.php or in the blesta code at vendors/minphp/bridge/src/View.php.

The reason other plugins don't encounter this error is because they don't try to access view files from the app directory, only from their own view directory.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...