Jump to content

Need help with module development


abyss996

Recommended Posts

Hello everyone!

 

I'm trying to learn module development for Prestashop. I'm trying to display a message at the front-end. Here's my code: 

<?php
class test extends Module {

	private $_html = '';
	function __construct() {
		$this -> name = 'test';
		$this -> tab = 'other';
		$this -> version = '0.1.0';
		$this -> author = 'Abyss';
		parent::__construct();
		$this -> displayName = $this -> l('My first module');
		$this -> description = $this -> l('This module does nothing yet.');
	}

	public function install() {

		parent::install();
		if (!$this -> registerHook('topcolumn') || !$this->registerHook('header'))
			return false;
		return true;

	}

	public function getContent() {

		if (Tools::isSubmit('submit_text')) {

			Configuration::updateValue($this -> name . 'text_to_show', Tools::getValue('the_text'));

		}
		$this -> _generateForm();
		return $this -> _html;
	}

	private function _generateForm() {

		$textToShow = Configuration::get($this -> name . 'text_to_show');

		$this -> _html .= '<form action="' . $_SERVER['REQUEST_URI'] . '" method="post">';
		$this -> _html .= '<label>' . $this -> l('Enter your text: ') . '</label>';
		$this -> _html .= '<div class="margin-form">';
		$this -> _html .= '<input type="text" name="the_text" value="' . $textToShow . '" >';
		$this -> _html .= '<input type="submit" name="submit_text" ';
		$this -> _html .= 'value="' . $this -> l('Update the text') . '" class="button" />';
		$this -> _html .= '</div>';
		$this -> _html .= '</form>';

	}
	
	public function hookTopColumn($params){
		global $smarty;
		
		$smarty->assign("our_text", Configuration::get($this->name."text_to_show"));
		
		return $this->display(__FILE__, "test.tpl");
	}


}

I want to display "our_text" next to the store's logo which is above the categories and the search bar. I tried this for the left column and it works fine. But what is the hook that I need to use in order to put it where Ive mentioned.

 

I've used registerHook('top') also. but it's not working

Please help me on this. Thanks in advance

 

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