espoCRM first steps in development

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mediaseer
    Junior Member
    • Apr 2025
    • 3

    espoCRM first steps in development

    Hi everyone,

    I’ve been trying to add a custom portal page to my EspoCRM installation (v9.0.6) but I keep hitting a wall — no matter what I do, the route returns a 404. 🧩 What I’ve Done:
    • Manually placed JS files in client/custom/src/portal/views/my-custom-page.js and client/custom/src/portal/routes.js
    • Verified frontend/libs.json exists
    • Confirmed client/src/view.js is present
    • Set useCache => false and isDeveloperMode => true in data/config.php
    • Ran php rebuild.php and also cleared data/cache/ manually
    • Checked for data/cache/client-custom.json — it’s never generated
    • When testing Espo.require('customortal/views/my-custom-page') in the portal console, I get Module not found
    🧪 Other Details:
    • Portal ID is correct
    • Custom route name is #MyCustomPage
    • Page defined using the standard view class
    • File permissions appear fine
    • I’ve tried this both on Cloudways and Krystal.io — same result

    It seems Espo’s rebuild process isn’t registering the JS files at all. Has anyone seen this before? Is there a rebuild debug mode or something else I can check?

    Thanks in advance for any insights 🙏

    — Clive
  • yuri
    Member
    • Mar 2014
    • 8845

    #2
    Hi,

    Could you show your frontend route file?

    You need a client route file and a controller class. Then, that controller would create a view. But you could just start with the route + controller. Then, move further as you got the controller action called when the needed URI is opened.

    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • mediaseer
      Junior Member
      • Apr 2025
      • 3

      #3
      Hi Yuri

      Here’s my custom frontend route file:

      Click image for larger version

Name:	Screenshot_851.png
Views:	41
Size:	70.7 KB
ID:	116530

      Code:
      define('custom:portal/routes', ['portal:routes'], function (Dep) {
      
      Dep.prototype.routes['MyCustomPage'] = 'actionMyCustomPage';
      
      Dep.prototype.actionMyCustomPage = function () {
      this.main('custom:portal/views/my-custom-page'); 
      };
      
      return Dep;
      });
      I haven’t added a separate controller yet, just using main(...) to directly render the view.

      But I can also try switching to a dedicated controller like this:

      Code:
      define('custom:portal/controllers/my-custom-page', ['controller'], function (Dep) {
          return Dep.extend({
              actionIndex: function () {
                  this.createView('myCustomPage', 'custom:portal/views/my-custom-page', {}, function (view) {
                      view.render();
                  });
              }
          });
      });
      ​
      Then use the route:

      Code:
      Dep.prototype.routes['MyCustomPage'] = 'myCustomPage/index';
      ​
      Would that be the more appropriate approach?

      Thanks

      Clive

      Comment

      • yuri
        Member
        • Mar 2014
        • 8845

        #4
        We don't have such route classes. I recommend to try follow the documentation first.

        You need to create define a route in JSON in metadata: https://docs.espocrm.com/development.../#custom-route

        Then the controller. Your controller looks legit.
        If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

        Comment

        • mediaseer
          Junior Member
          • Apr 2025
          • 3

          #5
          Hi Yurii,

          Thanks for the pointer.

          I've followed the example from the documentation:


          I successfully created a custom client-side route and confirmed that the controller works — I can extract and log values from the URL using options.id in the console.

          However, when I moved on to testing the Rendering view example, I ran into an issue:
          Running this:

          php rebuild.php

          cat data/cache/client-custom.json | grep views/account/test


          Returns:

          cat: data/cache/client-custom.json: No such file or directory

          So client-custom.json isn’t being generated at all, and that prevents the frontend from resolving the view path, leading to errors like:


          GET .../api/v1/Account/234 404 (Not Found)

          The files exist at:

          client/custom/src/controllers/my-controller.js

          client/custom/src/views/account/test.js


          And I’m using the code exactly as shown in the Rendering view section of the docs.

          Interestingly, rebuild does regenerate other cache files — just not client-custom.json.

          Any thoughts on what might prevent client-custom.json from being created? Could something in the JS files be preventing them from being picked up?

          Thanks again!

          Clive

          Comment

          Working...