customize the actions button in detailview

Hello everyOne.
I want to know how can i custom the actions button in detailview.
In this moment my action_menu btn of Contract module is look like:
actionBtnDetailView_EN.PNG
So my need :
- Hide viewChange_log btn for all users EXCEPT ADMIN
- if (status_ctr == 'Signed'){
               hide edit btn;
               hide delete btn;
   }

Thank u for ur help

Parents
  • You can override the include/DetailView/header.tpl file for your module. And add condition on the tpl file to hide the buttons.

    Overriding can be done in detailviewdefs.php for your module.

    'headerTpl' => 'custom/modules/YOURMODULE/tpls/DetailViewHeader.tpl',

    add the above mentioned line inside the 'form' key of the array.

    'form' => array(

        'headerTpl'=>'custom/modules/YOURMODULE/tpls/DetailViewHeader.tpl'

    ),

    Then copy the include/DetailView/header.tpl to custom/modules/YOURMODULE/tpls/DetailViewHeader.tpl

    Now in your view.detail.php file pass value the tpl file and in the tpl file add condition to show hide the buttons.

  • Thank u for ur replay
    But how can i pass value from view.detail.php file to the tpl insugarcrm ??

  • Hi Soukina,

    You can do this by just extending the detail view of your module.

    create a new view.detail.php file in the following path custom/modules/<YourMODULE>/views/view.detail.php

    add the below code

    <?php

    require_once('include/MVC/View/views/view.detail.php');

    class <YourMODULE>ViewDetail extends ViewDetail{

         //override the desplay() method

         function display(){

                   parent::display();

                   global $current_user;

                   $is_admin = $current_user->is_admin;

                     echo $script=<<<EOC

                     <script>

                          $('.ab').click(function(){

                               var is_admin = "$is_admin";

                                //hide view change log for non admin users

                               if(!is_admin){

                                    $('#btn_view_change_log').hide();

                               }

                          });

                     </script>

    EOC;

         }

    }

    Same way you can hide edit and delete button based on the  value of field 'status_ctr'. To get the value of any field in the view.detail.php file you can use $this->bean->field_name. In your case $this->bean->status_ctr

    Hope it helps!

    -Shijin Krishna

  • Thank u Krishna for ur replay .
    But this code is not working for me , how can i use a global variable of sugarCRM in JS code ?

Reply Children