Announcement

Collapse
No announcement yet.

add button to display template

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

  • add button to display template

    Is there a way to modify a display template to pull in a variable? I'd like to modify crm/res/templates/record/panels/activities.tpl to include a button linking to another page. I'd like to pass the account id variable to the url I'm hardcoding in. I currently have the button displaying and it works if I hardcode the id number in, but I want the button to work for each account it's on. It was 100 times faster for me to create this basic php page (AllAccountNotes.php) and I'd like to display it based on the account id.

    I tried {{account.id}} and {{{account.id}}} but these don't work.. I think those are for email or pdf templates and not the actual program templates? It's difficult to search for this as it's the same name as a feature.

    I currently have it looking like this:

    <div class="btn-group button-container">
    <button class="btn btn-default"><a href="http:MyDomain/basicCode/AllAccountNotes.php?id=587627496bbd187f8">View All Notes</a></button>
    <button class="btn btn-default all{{#ifEqual currentTab 'all'}} active{{/ifEqual}} scope-switcher" data-scope="">{{translate 'All'}}</button>
    {{#each tabList}}
    <button class="btn btn-default all{{#ifEqual ../currentTab this}} active{{/ifEqual}} scope-switcher" data-scope="{{./this}}">{{translate this category='scopeNamesPlural'}}</button>
    {{/each}}
    </div>

    <div class="list-container">
    {{{list}}}
    </div>

    Any hint or help is welcome.

  • #2
    hello
    better to do it in view
    client/modules/crm/src/views/record/panels/activities.js
    in this file set in data function values, you want to pass

    it's not upgrade safe

    Comment


    • #3
      I created a duplicate of the activities.tpl and then added {{{accountId}}} in the crm/res/templates/record/panels/account-activities.tpl
      On the client/modules/crm/src/views/record/panels/history.js I changed the template to crm:record/panels/account-activities

      Then in my client/modules/crm/src/views/record/panels/activities.js I've modified the data:function like this:

      data: function () {
      return {
      currentTab: this.currentTab,
      scopeList: this.scopeList,
      tabList: this.tabList,
      accountId: this.accountId
      };
      },


      then I modified the setup: function to include this:

      setup: function () {

      if (this.model.name == "Account"){
      this.accountId = this.model.id;
      }

      if (this.model.name == "Contact"){
      this.accountId = this.model.get('accountId');
      }


      This makes it usable on both the Account and Contact pages that I have the history panel enabled.
      Attached Files
      Last edited by joy11; 10-20-2017, 08:20 PM.

      Comment

      Working...
      X