Jump to content

Change link (advertising module)


Recommended Posts

Hey Guys

Im having some trouble making my link work for my advertising module... Ive changed it via. the .php file and thru BO... But it still links to my own site..

Anyone ever heard of this problem?

<?php

class BlockAdvertising extends Module
{
   public $adv_link;
   public $adv_img;
   public $adv_imgname;

   function __construct()
   {
       $this->name = 'blockadvertising';
       $this->tab = 'Blocks';
       $this->version = 0.1;

       parent::__construct();

       $this->displayName = $this->l('Block advertising');
       $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.png';
       else
           $this->adv_img = _MODULE_DIR_.$this->name.'/'.$this->adv_imgname;
       $this->adv_link = htmlentities(Configuration::get('BLOCKADVERT_LINK'), ENT_QUOTES, 'UTF-8');
   }


   function install()
   {
       Configuration::updateValue('BLOCKADVERT_LINK', 'MY LINK');
       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('BLOCKADVERT_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">
'.$this->l('Advertising block configuration').'
adv_link.'" target="_blank" title="'.$this->l('').'">';
       if ($this->adv_img)
           echo 'adv_img.'" alt="'.$this->l('Advertising image').'" style="margin-left: 100px;"/>';
       else
           echo $this->l('no image');
       echo '





'.$this->l('Change image').'  <input id="adv_img" type="file" name="adv_img" />




'.$this->l('Image link').'  <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;"/>

</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__, 'blockadvertising.tpl');
   }

   function hookLeftColumn($params)
   {
       return $this->hookRightColumn($params);
   }

}

?>

Link to comment
Share on other sites

Hi,

Try go to Admin>modules> Block advertising v0.1 and click configure - there you can change the link of the image...

Hope this helps.


Ive tried that, but the link does not change :(

Was hoping someone could read thru my code to see if there is something wrong
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...