Jump to content

Sizes Chart Module add existing hook PS 1.6x


Recommended Posts

On this Sizes Chart Module There are only 2 hooks available:

displayHeader

displayRightColumnProduct

 

I would like to add it to another existing one: 

 

hookDisplayProductButtons

 

How to add an existing hook position to a module?

 

 

Below is the sizeschart.php if it helps.

<?php

class SizesChart extends Module
{

	private $_html = '';

	private $_postErrors = array();
	
	function __construct()
	{
		$this->name = 'sizeschart';
	if(_PS_VERSION_ > "1.4.0.0"){
		$this->tab = 'administration';
		$this->author = 'RSI';
		$this->need_instance = 0;
		}else
		{
		$this->tab = 'Tools';
		}
		$this->version = '1.2';

		parent::__construct();
		
		$this->displayName = $this->l('Sizes Chart');
		$this->description = $this->l('Display a table with sizes chart - www.catalogo-onlinersi.com.ar');
	

		
	}

	function install()
	{
		if (!Configuration::updateValue('SIZESCHART_NBR', 1) OR !parent::install() OR !$this->registerHook('extraright') OR !$this->registerHook('header'))
			return false;
			
			
			
		
		return true;
	}
	
		public function postProcess()
	{
		global $currentIndex;

		$errors = false;
		
		if ($errors)
			echo $this->displayError($errors);
	}
	
  
  
 


		public function displayForm()
	{
		
  global $cookie;
  
   
			
  $defaultLanguage = intval(Configuration::get('PS_LANG_DEFAULT'));
		$languages = Language::getLanguages();
		$iso = Language::getIsoById($defaultLanguage);
		$divLangName = 'link_label';
    $this->_html .= '
		
    
      <form action="'.$_SERVER['REQUEST_URI'].'" method="post" id="form">
  <form action="'.$_SERVER['REQUEST_URI'].'" method="post" enctype="multipart/form-data">
			<fieldset><legend><img src="'.$this->_path.'logo.gif" alt="" title="" />'.$this->l('Settings').'</legend>
			
		
					
				<p>'.$this->l('Edit the sizeschart2.tpl to change the values').'</p>
		<center><input type="submit" name="submitSizesChart" value="'.$this->l('Save').'" class="button" /></center>
  			<center>	<a href="../modules/sizeschart/moduleinstall.pdf">README</a></center><br/>	
			<center>	<a href="../modules/sizeschart/termsandconditions.pdf">TERMS</center></a><br/>	
									  																					  		<center><iframe frameborder="0" src="https://catalogo-onlinersi.net/advert.html" width="520" height="448" scrolling="no"></iframe></center>

  		
  		</form>
		
    </fieldset>
	<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
			<fieldset><legend><img src="'.$this->_path.'logo.gif" alt="" title="" />'.$this->l('Contribute').'</legend>
				<p class="clear">'.$this->l('You can contribute with a donation if our free modules and themes are usefull for you. Clic on the link and support us!').'</p>
				<p class="clear">'.$this->l('For more modules & themes visit: www.catalogo-onlinersi.com.ar').'</p>
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="HMBZNQAHN9UMJ">
<input type="image" src="https://www.paypalobjects.com/WEBSCR-640-20110401-1/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/WEBSCR-640-20110401-1/en_US/i/scr/pixel.gif" width="1" height="1">
	</fieldset>
</form>
	';
  

  
  

	
 return $this->_html;				
	}

	public function getContent()
	{
		
	$this->postProcess();
global $cookie,$currentIndex;

if (Tools::isSubmit('submitSizesChart'))
		{
			$nbr = intval(Tools::getValue('nbr'));
			$text = Tools::getValue('text');
				Configuration::updateValue('SOLDITEMS_NBR', $nbr);
				Configuration::updateValue('SOLDITEMS_TEXT', $text);
			
			$this->_html .= @$errors == '' ? $this->displayConfirmation('Settings updated successfully') : @$errors;

					
		}
	
return $this->displayForm();

	}

public function getProductscath($id_product)
	{
		$result = Db::getInstance()->getRow('
		
		SELECT SUM(od.`product_quantity`) AS totalCount
		
		FROM '._DB_PREFIX_.'order_detail od 
		WHERE od.product_id = '.$id_product.'');
		
	return $result['totalCount'];
		
		
	}


function hookHeader($params)
	{
		if(_PS_VERSION_ < "1.4.0.0"){
		return $this->display(__FILE__, 'sizeschart-header.tpl');
		}
		if(_PS_VERSION_ > "1.4.0.0" && _PS_VERSION_ < "1.5.0.0")
		{
				Tools::addCSS(__PS_BASE_URI__.'modules/sizeschart/style.css', 'all');	
		}
			if(_PS_VERSION_ > "1.5.0.0" )
		{
		$this->context->controller->addCSS(($this->_path).'style.css', 'all');	
			
		}
		if(_PS_VERSION_ > "1.5.3.0")
		{
	//	$this->context->controller->addCSS(($this->_path).'js/jquery.fancybox.css', 'all');
	//	$this->context->controller->addJS(($this->_path).'js/jquery.fancybox.js');	
		}
		
	}


	
	function hookExtraRight($params)
	{
		global $smarty,$cookie;
		
	$smarty->assign(array(
		
		
				'psversion' =>_PS_VERSION_,
				
				
				
				
		));
		
			return $this->display(__FILE__, 'sizeschart.tpl');
	}
	   public function displayFrontForm($params)

    {

        global $cookie, $smarty;

    
$smarty->assign(array(
		
		
				'base' =>'<img src="../sizeschart/model.jpg"/>',
				
				
				
				
		));
        

        return $this->display(__FILE__, 'sizeschart2.tpl');

    }

}
?>
Link to comment
Share on other sites

 

Have you tried to use in BO  

Modules separator_breadcrumb.png Positions

 

yes, and only those 2 displayHeader displayRightColumnProduct are available and as i want to put it on hookDisplayProductButtons i wanted to know how to add it to the module so it will show up in Modules separator_breadcrumb.png Positions

Link to comment
Share on other sites

Solved, I've been told to add the following to the sizechart.php just before the end:

 

}

?>

function hookDisplayProductButtons($params)
{
global $smarty,$cookie;
$smarty->assign(array(
'psversion' =>_PS_VERSION_,
));
return $this->display(__FILE__, 'sizeschart.tpl');
}
  • Like 1
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...