Need help creating custom view/template for the contact enity

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • devespo
    Junior Member
    • May 2017
    • 15

    Need help creating custom view/template for the contact enity

    I am reading documentation for creating custom views at: https://www.espocrm.com/documentatio.../custom-views/

    Can built in entity types have their views overridden? Or is this for Custom entities only?

    What is the difference between views and recordViews?

    I tried to override detail view of the Contact entity as follows

    Following instructions I created file:

    custom/Espo/Custom/Resources/metadata/clientDefs/Contact.json
    Code:
    {
      "recordViews": {
        "detail": "custom:views/contact/record/detail"
      }
    }
    The I created following file:

    client/custom/src/views/contact/record/detail.js
    Code:
    Espo.define('custom:views/contact/record/detail', 'views/record/detail', function (Dep) {
    
      return Dep.extend({
        template: 'custom:views/contact/record/detail',
    
        setup: function () {
          Dep.prototype.setup.call(this);
        },
    
        afterRender: function () {
          Dep.prototype.afterRender.call(this);
        }
      });
    });

    Then I created following file:

    client/custom/res/templates/contact/record/detail.tpl
    By
    cp client/res/templates/record/detail.tpl client/custom/res/templates/contact/record/detail.tpl
    And adding a minor "hellow world" text at the beginning of the first div.

    In admin I rebuilt the crm.

    I am not seeing the hello world in contact entity record detail page.


    What am I missing here?
  • Andorxor
    Member
    • May 2019
    • 65

    #2
    Did you reload the page?

    Comment

    • yuri
      Member
      • Mar 2014
      • 8440

      #3

      Change:

      template: 'custom:views/contact/record/detail'
      =>
      template: 'custom:contact/record/detail'

      I recommend checking browser console
      Last edited by yuri; 09-27-2019, 10:30 AM.
      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

      • devespo
        Junior Member
        • May 2017
        • 15

        #4
        Thank you Yuri, that fixed the issue. How can I access entity variable in this template so that I can use if in iframe src?

        Comment

        • yuri
          Member
          • Mar 2014
          • 8440

          #5
          Check https://github.com/espocrm/documenta...opment/view.md

          {{viewObject.someParam1}}
          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

          • devespo
            Junior Member
            • May 2017
            • 15

            #6
            Thank you Yuri, I was able to access it with {{viewObject.attributes.someParam1}}

            Comment

            • bandtank
              Active Community Member
              • Mar 2017
              • 379

              #7
              What is the difference between views and recordViews?
              Did you ever figure this out? I have the same questions.

              Comment

            Working...