Jump to content

Hide config page toolbars from within module


Recommended Posts

Hi

I've viewed a number of forums posts, but couldn't find the answer I'm looking for really.

I need to hide some/all of the buttons you see in the screenshot, but this needs to be done from within the module.

Can it be done, and how?

I did try good old js/css, but I think there's an issue doing that to affect something that doesn't exist within the module.

 

 

Thanks

Screenshot 2022-09-06 at 16.12.20.png

Link to comment
Share on other sites

  • 2 weeks later...

Module:

...
$this->registerHook('actionAdminControllerSetMedia');

public function hookActionAdminControllerSetMedia($params)
{
    
    $modules = array('ps_facetedsearch', 'contactform', $this->name);

    if($this->context->controller->controller_name == 'AdminModules' && in_array(Tools::getValue('configure'), $modules))
    {
        $jsDef = [];        
        foreach ($modules as $module){
            if ($module == 'ps_facetedsearch'){
                $jsDef = [
                    'button_back' => 'show',
                    'button_translate' => 'hide',
                    'button_update' => 'hide',
                    'button_hooks' => 'hide',
                ];
             }

            if ($module == 'contactform'){
                $jsDef = [
                    'button_back' => 'hide',
                    'button_translate' => 'hide',
                    'button_update' => 'hide',
                    'button_hooks' => 'hide',
                ];
             }

            if ($module == $this->name){
                $jsDef = [
                    'button_back' => 'show',
                    'button_translate' => 'show',
                    'button_update' => 'hide',
                    'button_hooks' => 'show',
                ];
             }
        }
        Media::addJsDef($jsDef);
        $this->context->controller->addJS(_PS_MODULE_DIR_.$this->name.'/views/js/admin.js');
    }

}

and javascript:

$(document).ready(function(){
    if (button_back == 'hide') {
        document.getElementById('desc-module-back').style.display = 'none';
    };
  
    if (button_translate == 'hide') {
        document.getElementById('desc-module-translate').style.display = 'none';
    };
  
    if (button_update == 'hide') {
        document.getElementById('desc-module-update').style.display = 'none';
    };
  
    if (button_hooks == 'hide') {
        document.getElementById('desc-module-hook').style.display = 'none';
    };
});

 

Edited by 4you.software (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...