Announcement

Collapse
No announcement yet.

Need help creating custom view/template for the contact enity

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

  • 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?

  • #2
    Did you reload the page?

    Comment


    • #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.

      Comment


      • #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


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

          {{viewObject.someParam1}}

          Comment


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

            Comment


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

              Comment

            Working...
            X