Announcement

Collapse
No announcement yet.

Extension: controller not found

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Extension: controller not found

    Hi,

    first of all thanks for EspoCRM.

    I am writing an extension which will let me interact with Nextcloud API. You can find attached the relevant code.

    The extension correctly appears in the menu, but when I click on the menu item I get a 404 error, saying: "Nextcloud controller not found".

    Could you help me figure out what I am doing wrong?


    Thank you.
    Attached Files

  • #2
    After more debugging with the help of some logs, I found a typo. In Nextcloud.php, under Controllers, this line:

    PHP Code:
    namespace Espo\Module\Nextcloud\Controllers
    must be:

    PHP Code:
    namespace Espo\Modules\Nextcloud\Controllers

    Comment


    • #3
      Hello
      check backend controller namespace (Module{s})

      Comment


      • #4
        Thank you, tanya.

        I have another question, don't know if I can ask here or you need me to open a different topic.

        I can now call my external API correctly and get a JSON back in the response. How can I display the result in my template? If you check the attached source code, I have an index.tpl file. I want to print the JSON in that file. Is it possible?

        Comment


        • #5
          create other view for results and render results view after response

          client/src/views/list.js -> createListRecordView function (loadList) -> to view client/src/views/record/list.js

          Comment


          • #6
            Sorry, but I don't understand. Could you share more details? I mean:

            - do I have to add another file under espocrm-nextcloud/files/client/modules/nextcloud/src/views?
            - do I have to extend client/src/views/list.js somehow?
            - it seems to me client/src/views/record/list.js operates on clientDefs. How can it operate on data coming from an external JSON?

            Thank you.

            Comment


            • #7
              - it's desirable
              - no
              - pass it in 'data'

              Comment


              • #8
                Originally posted by tanya View Post
                - pass it in 'data'
                Do you mean something like this:
                PHP Code:
                Espo.define('nextcloud:controllers/nextcloud''controller', function (Dep) {
                    return 
                Dep.extend({
                        
                carter: function () {
                            var 
                result;
                            $.
                ajax({
                                
                url'Nextcloud/action/tweets',
                                
                type'GET',
                                
                dataType'json',
                                
                asyncfalse,
                                
                success: function (data) {
                                    
                result data;
                                }
                            });
                            return 
                result;
                        },

                        
                getSettingsModel: function () {
                            var 
                model this.getConfig().clone();
                            
                model.defs this.getConfig().defs;

                            return 
                model;
                        },

                        
                index: function (options) {
                            var 
                result this.carter();

                            var 
                model this.getSettingsModel();
                            
                this.main('nextcloud:views/nextcloud/index', {
                                
                modelmodel,
                                
                dataresult
                            
                });
                        }
                    });
                }); 

                This seems to be working, I can see the contents of "data" if I logged it on the JS console.

                PHP Code:
                Espo.define('nextcloud:views/nextcloud/index''view', function (Dep) {
                    return 
                Dep.extend({

                        
                template'nextcloud:nextcloud/index',

                        
                init: function () {
                            
                console.log('result: ' JSON.stringify(this.datanull2));
                        }

                    })
                }); 

                I still don't understand how to have it displayed in index.tpl, though.
                Last edited by manuel7b; 09-20-2017, 11:42 AM.

                Comment


                • #9
                  I managed to print the content of data using:
                  HTML Code:
                  <div>
                      {{#each ./this}}
                      <h2>{{text}}</h2>
                      {{/each}}
                  </div>
                  Thanks for the support.

                  Comment


                  • #10
                    Sorry if I keep asking question, I am still learning.

                    What if now I want to show the results in a list like, say, the one already existing for Opportunities?

                    Comment

                    Working...
                    X