Jump to content
distributionkelly

[FREE MODULE]Addthis module for PS1.6

Recommended Posts

Hello;

 

[sharing] I gonna share this addthis module developped by dh42. This module works fine with PS1.5 and 1.6. It works not only the ADDTHIS code but all other sharing buttons codes like Sharethis, addtoany etc as you've got the right sharing button code.

 

012p.png

64cz.png

[Problem] Since I am novice in developping modules, can anyone in this forum help to develop this module into Multi-language, which means in different languages; customers have different sharing buttons. For example; in English; people get facebook sharing button; but in French; only twitter shows.

 

I think the php should be modified; please see the following code:

if (!defined('_CAN_LOAD_FILES_'))
	exit;
class Addthismodule extends Module
{
	public function __construct()
	{
		$this->name = 'addthismodule';
		if (version_compare(_PS_VERSION_, '1.4.0.0') >= 0)
			$this->tab = 'front_office_features';
		else
			$this->tab = 'Blocks';
		$this->version = '1.0';
		$this -> author = 'dh42';
		parent::__construct();
		$this->displayName = $this->l('Add This Module');
		$this->description = $this->l('Add This social sharing module');
	}
	public function install()
	{
		$this->_clearCache('addthismodule.tpl');
		return (parent::install()
				&& Configuration::updateValue('productpage_val', '')
				&& Configuration::updateValue('productenabled', '')
				&& Configuration::updateValue('welcome_val', '')
				&& Configuration::updateValue('bar_homepage', '')
				&& Configuration::updateValue('bar_cms', '')
				&& Configuration::updateValue('bar_category', '')
				&& Configuration::updateValue('bar_product', '')
				&& Configuration::updateValue('bar_contact', '')
				&& Configuration::updateValue('smart_val', '')
				&& Configuration::updateValue('smart_homepage', '')
				&& Configuration::updateValue('smart_cms', '')
				&& Configuration::updateValue('smart_product', '')
				&& Configuration::updateValue('smart_contact', '')
				&& Configuration::updateValue('smart_category', '')
				&& $this->registerHook('footer')
				&& $this->registerHook('displayleftcolumnproduct') && $this->registerHook('displayBackOfficeHeader'));
	}
	public function uninstall()

	{

		$this->_clearCache('addthismoduleproduct.tpl');
		$this->_clearCache('addthismodule.tpl');
		return (
			!Configuration::deleteByName('productpage_val') ||
			!Configuration::deleteByName('productenabled') ||
			!Configuration::deleteByName('welcome_val') ||
			!Configuration::deleteByName('bar_homepage') ||
			!Configuration::deleteByName('bar_cms') ||
			!Configuration::deleteByName('bar_category') ||
			!Configuration::deleteByName('bar_product') ||
			!Configuration::deleteByName('bar_contact') ||
			!Configuration::deleteByName('smart_val') ||
			!Configuration::deleteByName('smart_homepage') ||
			!Configuration::deleteByName('smart_cms') ||
			!Configuration::deleteByName('smart_product') ||
			!Configuration::deleteByName('smart_contact') ||
			!Configuration::deleteByName('smart_category') ||
			 parent::uninstall());
	}
	public function getContent()
	{
		$html = '';
		if (isset($_POST['submitModule']))
		{
			Configuration::updateValue('productpage_val', ((isset($_POST['productpage']) && $_POST['productpage'] != '') ? $_POST['productpage'] : ''),  true);
			Configuration::updateValue('welcome_val', ((isset($_POST['welcome']) && $_POST['welcome'] != '') ? $_POST['welcome'] : ''),  true);
			Configuration::updateValue('bar_homepage', Tools::getValue('bar_homepage'));
			Configuration::updateValue('bar_cms', Tools::getValue('bar_cms'));
			Configuration::updateValue('bar_category', Tools::getValue('bar_category'));
			Configuration::updateValue('bar_product', Tools::getValue('bar_product'));
			Configuration::updateValue('bar_contact', Tools::getValue('bar_contact'));
			Configuration::updateValue('smart_val', ((isset($_POST['welcome']) && $_POST['smart'] != '') ? $_POST['smart'] : ''),  true);
			Configuration::updateValue('smart_homepage', Tools::getValue('smart_homepage'));
			Configuration::updateValue('smart_cms', Tools::getValue('smart_cms'));
			Configuration::updateValue('smart_category', Tools::getValue('smart_category'));
			Configuration::updateValue('smart_product', Tools::getValue('smart_product'));
			Configuration::updateValue('smart_contact', Tools::getValue('smart_contact'));
			Configuration::updateValue('productenabled', Tools::getValue('productenabled'));
			$html .= '<div class="confirm" style="height: 40px;padding-left: 40px;line-height: 40px;">'.$this->l('Configuration updated').'</div>';
		}
		$html .= '
		<h2>'.$this->displayName.'</h2>
		<form action="'.$_SERVER['REQUEST_URI'].'" method="post">
			<fieldset>
				<p><label for="productpage">'.$this->l('Product Page Share Buttons').' :</label>
				<textarea id="productpage" name="productpage" cols="100" rows="5">'.Configuration::get('productpage_val').'</textarea></p>
				<div class="margin-form">
				<input type="checkbox" name="productenabled" value="1" '.(Tools::getValue('productenabled', Configuration::get('productenabled')) ? 'checked="checked" ' : '').'>Enabled
				</div>
			</fieldset>
			<fieldset>
				<p><label for="welcome">'.$this->l('Welcome Bar').' :</label>
				<textarea id="welcome" name="welcome" cols="100" rows="5">'.Configuration::get('welcome_val').'</textarea>
				</p>
				<div class="margin-form">
				<p>Check the pages you want the bar displayed on</p>
				<input type="checkbox" name="bar_homepage" value="1" '.(Tools::getValue('bar_homepage', Configuration::get('bar_homepage')) ? 'checked="checked" ' : '').'>Home Page
				<input type="checkbox" name="bar_cms" value="1" style="margin-left:15px;" '.(Tools::getValue('bar_cms', Configuration::get('bar_cms')) ? 'checked="checked" ' : '').'>CMS Pages
				<input type="checkbox" name="bar_category" value="1" style="margin-left:15px;" '.(Tools::getValue('bar_category', Configuration::get('bar_category')) ? 'checked="checked" ' : '').'>Category Pages
				<input type="checkbox" name="bar_product" value="1" style="margin-left:15px;" '.(Tools::getValue('bar_product', Configuration::get('bar_product')) ? 'checked="checked" ' : '').'>Product Pages
				<input type="checkbox" name="bar_contact" value="1" style="margin-left:15px;" '.(Tools::getValue('bar_contact', Configuration::get('bar_contact')) ? 'checked="checked" ' : '').'>Contact Page
				</div>
			</fieldset>
			<fieldset>
				<p><label for="smart">'.$this->l('Smart Layers').' :</label>
				<textarea id="smart" name="smart" cols="100" rows="5">'.Configuration::get('smart_val').'</textarea>
				</p>
				<div class="margin-form">
				<p>Check the pages you want the Smart Layers displayed on</p>
				<input type="checkbox" name="smart_homepage" value="1" '.(Tools::getValue('smart_homepage', Configuration::get('smart_homepage')) ? 'checked="checked" ' : '').'>Home Page
				<input type="checkbox" name="smart_cms" value="1" style="margin-left:15px;" '.(Tools::getValue('smart_cms', Configuration::get('smart_cms')) ? 'checked="checked" ' : '').'>CMS Pages
				<input type="checkbox" name="smart_category" value="1" style="margin-left:15px;" '.(Tools::getValue('smart_category', Configuration::get('smart_category')) ? 'checked="checked" ' : '').'>Category Pages
				<input type="checkbox" name="smart_product" value="1" style="margin-left:15px;" '.(Tools::getValue('smart_product', Configuration::get('smart_product')) ? 'checked="checked" ' : '').'>Product Pages
				<input type="checkbox" name="smart_contact" value="1" style="margin-left:15px;" '.(Tools::getValue('smart_contact', Configuration::get('smart_contact')) ? 'checked="checked" ' : '').'>Contact Page
				</div>
			</fieldset>
			<fieldset>
			<div class="margin-form">
					<input type="submit" name="submitModule" value="'.$this->l('Save').'" class="button" /></center>
			</div>
			</fieldset>
		</form>
		';
		return $html;
	}
public function hookdisplayFooter($params)
	{

		if (!$this->isCached('addthismodule.tpl', $this->getCacheId()))
	{
		global $smarty;
		$smarty->assign(array(
			'welcome_val' => Configuration::get('welcome_val'),
			'bar_homepage' => Configuration::get('bar_homepage'),
			'bar_category' => Configuration::get('bar_category'),
			'bar_cms' => Configuration::get('bar_cms'),
			'bar_product' => Configuration::get('bar_product'),
			'bar_contact' => Configuration::get('bar_contact'),
			'smart_val' => Configuration::get('smart_val'),
			'smart_homepage' => Configuration::get('smart_homepage'),
			'smart_category' => Configuration::get('smart_category'),
			'smart_cms' => Configuration::get('smart_cms'),
			'smart_product' => Configuration::get('smart_product'),
			'smart_contact' => Configuration::get('smart_contact')
		));
			}
return $this->display(__FILE__, 'addthismodule.tpl', $this->getCacheId());
	}
public function hookDisplayleftcolumnproduct($params)
	{

		if (!$this->isCached('addthismoduleproduct.tpl', $this->getCacheId()))
	{
		global $smarty;
		$smarty->assign(array(
			'productpage_val' => Configuration::get('productpage_val'),
			'productenabled' => Configuration::get('productenabled')
		));
			}
return $this->display(__FILE__, 'addthismoduleproduct.tpl', $this->getCacheId());
	}
	public function hookDisplayBackOfficeHeader($params)

	{

		if( isset($this->context->controller->dh_support) )

			return;

		$this->context->controller->dh_support = 1;
		if (version_compare(@_PS_VERSION_,'1.6','<'))
			$this->context->controller->addJS($this->_path . '/dh42_15.js', 'all');
		else
			$this->context->controller->addJS($this->_path . '/dh42.js', 'all');

		return;



	}
}

addthismodule.zip

Edited by distributionkelly (see edit history)

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More