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.

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

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

  • Here is the code you can use. Do change the Class name

    <?php

    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

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

    class LeadsViewDetail extends ViewDetail

    {

        function display()

        {

            global $sugar_config, $current_user;

             parent::display();

            $is_admin = $current_user->is_admin;

           

            $javascript_script=<<<EOQ

            <script>

                $(document).ready(function() {

                    var is_admin = "$is_admin";

                    if(!is_admin){

                        $("#btn_view_change_log").closest("li").hide();

                    }

                });

            </script>

    EOQ;

    echo $javascript_script;

        }

    }