Vote to Improve PrestaShop

PrestaShop Forum: Build a free online shop. Count on the Community!

The best place in the world to ask questions about PrestaShop and get advice from our passionate community!

PrestaShop Forum: Build a free online shop. Count on the Community!

Jump to content

Photo

Link Issue when having 4 block advertising


  • Please log in to reply
6 replies to this topic
SK01

    PrestaShop Apprentice

  • Members
  • PipPip
  • 47 posts

Posted 23 September 2010 - 10:36 PM

Hi. I have duplicated the blockadversiting module and renamed them like this;

blockadvertising

blockadvertising2

blockadvertising3

blockadvertising4

I have also made the changes in each .phop file. Everything works great, but the only problem I have is that when i change the link for 1 ad, it will change for all 4 ads - So i cant have 4 different links..

How can I make them link to specified pages?

Hope u understand what I mean :)
Have you been helped? Give something back - help others!

rocky

    PrestaShop Legend

  • US Moderators
  • 10064 posts

Posted 24 September 2010 - 02:08 AM

Did you duplicate the PrestaShop v1.2.5 advertising block or PrestaShop v1.3.1 advertising block?

If you are using the PrestaShop v1.2.5 one, simply change the link in modules/blockadvertising2/blockadvertising.tpl, for example, to a different link.

If you are using the PrestaShop v1.3 one, then you will need to replace 'BLOCKADVERT_LINK' in modules/blockadvertising2/blockadvertising2.php with 'BLOCKADVERT2_LINK'. Modify all the modules so that they all have a unique variable in the database, otherwise all the advertising blocks will overwrite each other's variables.
Nethercott Constructions - PrestaShop modules and guides

Addamz

    PrestaShop Apprentice

  • Members
  • PipPip
  • 26 posts

Posted 08 November 2010 - 09:16 AM

Hi. I have clone of module advertising from prestashop 1.3, but when I upload module to ftp and clik on backoffice/modules I can see only blank page, when I delete cloned module everything is OK. Can you help me?

This is my cloned ad module:

<?phpclass BlockAdvertising extends Module{    public $adv_link;    public $adv_img;    public $adv_imgname;    function __construct()    {        $this->name = 'blockadvertising2';        $this->tab = 'Blocks';        $this->version = 0.1;        parent::__construct();        $this->displayName = $this->l('Block advertising 2');        $this->description = $this->l('Adds a block to display an advertising');        $this->adv_imgname = 'advertising_custom.jpg';        if (!file_exists(dirname(__FILE__).'/'.$this->adv_imgname))            $this->adv_img = _MODULE_DIR_.$this->name.'/advertising.jpg';        else            $this->adv_img = _MODULE_DIR_.$this->name.'/'.$this->adv_imgname;        $this->adv_link = htmlentities(Configuration::get('BLOCKADVERT2_LINK'), ENT_QUOTES, 'UTF-8');    }    function install()    {        Configuration::updateValue('BLOCKADVERT2_LINK', 'http://www.prestashop.com');        if (!parent::install())            return false;        if (!$this->registerHook('rightColumn') OR !$this->registerHook('leftColumn'))            return false;        return true;    }    public function postProcess()    {        global $currentIndex;        $errors = false;        if (Tools::isSubmit('submitAdvConf'))        {            $file = false;            if (isset($_FILES['adv_img']) AND isset($_FILES['adv_img']['tmp_name']) AND !empty($_FILES['adv_img']['tmp_name']))            {                if ($error = checkImage($_FILES['adv_img'], 4000000))                    $errors .= $error;                elseif (!move_uploaded_file($_FILES['adv_img']['tmp_name'], dirname(__FILE__).'/'.$this->adv_imgname))                    $errors .= $this->l('Error move uploaded file');                $this->adv_img = _MODULE_DIR_.$this->name.'/'.$this->adv_imgname;            }            if ($link = Tools::getValue('adv_link'))            {                Configuration::updateValue('BLOCKADVERT2_LINK', $link);                $this->adv_link = htmlentities($link, ENT_QUOTES, 'UTF-8');            }        }        if ($errors)            echo $this->displayError($errors);    }    public function getContent()    {        $this->postProcess();        echo '<form action="'.$_SERVER['REQUEST_URI'].'" method="post" enctype="multipart/form-data"><fieldset><legend>'.$this->l('Advertising block configuration').'</legend><a >adv_link.'" target="_blank" title="'.$this->l('Advertising').'">';        if ($this->adv_img)            echo '<img >adv_img.'" alt="'.$this->l('Advertising image').'" style="margin-left: 100px;"/>';        else            echo $this->l('no image');        echo '</a><label for="adv_img">'.$this->l('Change image').'  </label><input id="adv_img" type="file" name="adv_img" /><label for="adv_link">'.$this->l('Image link').'  </label><input id="adv_link" type="text" name="adv_link" value="'.$this->adv_link.'" /><input class="button" type="submit" name="submitAdvConf" value="'.$this->l('validate').'" style="margin-left: 200px;"/></fieldset></form>';    }    /**    * Returns module content    *    * @param array $params Parameters    * @return string Content    */    function hookRightColumn($params)    {        global $smarty, $protocol_content, $server_host;        $smarty->assign('image', $protocol_content.$server_host.$this->adv_img);        $smarty->assign('adv_link', $this->adv_link);        return $this->display(__FILE__, 'blockadvertising2.tpl');    }    function hookLeftColumn($params)    {        return $this->hookRightColumn($params);    }}?>


rocky

    PrestaShop Legend

  • US Moderators
  • 10064 posts

Posted 09 November 2010 - 05:46 AM

Edit config/config.inc.php and temporarily change 'display_errors' from 'off' to 'on'. That should give you an error message instead of a blank tab. Post the error message here.
Nethercott Constructions - PrestaShop modules and guides

Addamz

    PrestaShop Apprentice

  • Members
  • PipPip
  • 26 posts

Posted 09 November 2010 - 06:12 AM

Hi. This is error:

Fatal error: Cannot redeclare class BlockAdvertising in /Applications/XAMPP/xamppfiles/htdocs/blue/classes/Module.php(323) : eval()'d code on line 115


rocky

    PrestaShop Legend

  • US Moderators
  • 10064 posts

Posted 09 November 2010 - 06:50 AM

You need to change:

class BlockAdvertising extends Module


to:

class BlockAdvertising2 extends Module


and rename the file to blockadvertising2.php and the directory to blockadvertising2
Nethercott Constructions - PrestaShop modules and guides

Addamz

    PrestaShop Apprentice

  • Members
  • PipPip
  • 26 posts

Posted 09 November 2010 - 12:53 PM

Thank you. Now is all OK.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users