Jump to content

AdminTab - adding and referencing new icon (1.6)


contentengineer

Recommended Posts

We are extending Prestashop 1.6 with a "Parent" AdminTab and multiple "child" AdminTabs referencing separate classes for adding specialist functionality.

The tab navigation works successfully, but we have become a little unstuck in defining the images that appear in the menu on the left and the page toolbar title at the top of each page (in green banner).

 

Where should the physical assets sit?

Which property of the Tab  or  AdminController should we be checking/linking?

 

Thanks

 

Rob

Link to comment
Share on other sites

We note that the "majority" of images for tabs USED to appear to be in /var/www/html/img/t/ as gif images; but since 1.6  are rendered using CSS3/Font Awesome, with entries such as:

 

.icon-heart:before { content: "\f004"; }  

.icon-AdminXyz:before { content: "\f099"; }

 

in css 

 

and in html:

 

<i class="icon-AdminXyz"> 

 

----

The problem we face in "tailoring" them is that:

 

icon-Admin##### are HARD coded into admin-theme.css;

and then added in function initBreadcrumbs (AdminController.php) at line 413/419

 

One option would be to override initBreadcrumbs() function 

An alternative option would be to modify $breadcrumbs2 which has been assigned to $this->context->smarty->assign('breadcrumbs2',$breadcrumbs)

Edited by contentengineer (see edit history)
Link to comment
Share on other sites

"Our" revised solution to tailoring the icon in the admin (back office) menu for a new AdminTab is to use the Back Office hook to supplement the admin-theme.css:

<?php
/* Skeleton module template
 * @version 0.8
 * @author RMS
 */ if (!defined('_PS_VERSION_'))
        exit;

class ModuleTemplate extends Module

public function install()
{
   ...
   $this->registerHook('displayBackOfficeHeader');
   ...
}

public function uninstall()
{
...
$this->unregisterHook('displayBackOfficeHeader');
...
}


public function hookDisplayBackOfficeHeader()
{
   $this->context->controller->addCss($this->_path.'css/tab.css');
}

...

 

And a file tab.css in  <store root>/modules/moduletemplate/css/

 
.icon-AdminModuleTemplate:before, .icon-AdminParentModuleTemplate:before { content: "\f004"; }
Edited by contentengineer (see edit history)
  • Like 2
Link to comment
Share on other sites

  • 10 months later...
  • 4 weeks later...
<?php    
if (!defined('_PS_VERSION_'))  
exit;

	class MyCrazyModule extends Module {

		public $modulname;

	
		public function __construct() {
	  
		  $this->name = 'mycrazymodule ';    
		  $this->tab = 'quick_bulk_update';    
		  $this->version = '1.0.0';    
		  $this->author = 'Author';    
		  $this->need_instance = 0;    
		  //$this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_);      
		  $this->bootstrap = true;    

		  parent::__construct();   
		  
		  $this->displayName = $this->l('My Crazy Module');    
		  $this->description = $this->l('Description of my Module');     
		  $this->confirmUninstall = $this->l('Are you sure you want to uninstall?');   
		   
		}


	
	
		public function install() {
		
			// PS_VERSION CHECK
			if (version_compare(_PS_VERSION_, '1.5.1.0') >= 0) 
			{
		
			$this->registerHook('displayBackOfficeHeader');
		
					if (!parent::install())
					{
					return false;
					}
			
				return true;
		
			}
			else
			{
					$this->_errors[] = $this->l('The version of your module is not compliant with your PrestaShop version.');
					return false;
			}
		
		}
	

		public function uninstall() {

		$this->unregisterHook('displayBackOfficeHeader');
					
					if (!parent::uninstall())
					{
					return false;
					}
			
			return true;
			
		}
	
	
	public function hookDisplayBackOfficeHeader() {
		$this->context->controller->addCss($this->_path.'css/tab.css');
	}
	

	}
	
	

css/tab.css

.icon-AdminMyCrazyModule:before, .icon-AdminMyCrazyModule:before { content: "\f019"; }

It doesn't work for me. Where is the error? The css file not even included in the header.

Edited by Chrims (see edit history)
Link to comment
Share on other sites

Hi Chrims,

 

Yea, you must do a registerHook once the "module's install" is successfully completed.

 

Do something like that

    public function install()
    {
        if (!parent::install()
            || !$this->installModuleTab()
            || !$this->installModuleDb()
            || !$this->registerHook('displayBackOfficeHeader')
            || !Configuration::updateValue('MYMODULE_NAME', 'CustomName')
        )
            return false;

        return true;
    }
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...