Jump to content

[SOLVED] Image mapping on the home page


Recommended Posts

Like in the category view, i would like to have a image mapping (scenes) on the home page.
There have been request before, but untill now no answers have been given.

I tried to add code to the /index.tpl but that didnt work.
Any clue which file i should change here ?

I have created an image map and enabled it for the home page. Strangely enough there are 2 home pages in prestashop possible.... :-O

Link to comment
Share on other sites

Add the following code to index.php in the root directory of Prestashop before the $smarty->display:

/* Scenes  (could be externalised to another controler if you need them */
$smarty->assign('scenes', Scene::getScenes(1, intval($cookie->id_lang), true, false));



Then you can put the following at the top of index.tpl in your theme's directory:

{if $scenes}
   <!-- Scenes -->
   {include file=$tpl_dir./scenes.tpl scenes=$scenes}
{/if}



Once you've done this, you can go to Catalog > Image mapping, edit an image map and tick the "Home" category. It is odd that Prestashop has the option to tick the "Home" category, but no code to display image maps on the homepage. It must be a bug in Prestashop, I guess.

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...

Hi! Rocky has a great solution, but it was missing one thing in index.php in order to work for me:

/* CSS ans JS files calls */
$css_files = array(__PS_BASE_URI__.'css/jquery.cluetip.css' => 'all', _THEME_CSS_DIR_.'scenes.css' => 'all');



Thank you Rocky!

Link to comment
Share on other sites

  • 2 weeks later...
Hello!
Where exactly did you put this missing text in index.php? Did you put it alone, or along with rocky's text? Thanks!


Hi, here is my complete index.php file
<?php

include(dirname(__FILE__).'/config/config.inc.php');

if(intval(Configuration::get('PS_REWRITING_SETTINGS')) === 1)
   $rewrited_url = __PS_BASE_URI__;

/* CSS ans JS files calls */
$css_files = array(__PS_BASE_URI__.'css/jquery.cluetip.css' => 'all', _THEME_CSS_DIR_.'scenes.css' => 'all');

include(dirname(__FILE__).'/header.php');

$smarty->assign('HOOK_HOME', Module::hookExec('home'));

/* Scenes  (could be externalised to another controler if you need them */
$smarty->assign('scenes', Scene::getScenes(1, intval($cookie->id_lang), true, false));

$smarty->display(_PS_THEME_DIR_.'index.tpl');

include(dirname(__FILE__).'/footer.php');

?>

  • Like 1
Link to comment
Share on other sites

  • 4 months later...
  • 3 months later...

i cant get this to work neither and i have version 3.1.1 also . also instead of mapping it to a product page how about to a Manufacturers link on the site and remove the little gray box.

on my home page i have a Image with Manufacturers i sell for and it will be cool to map the image to the Manufacturers by their logos on the image www.projectpb.com

Thanks Jeff

Link to comment
Share on other sites

  • 4 weeks later...

I just wanted to say that there are lots of places that lead to this thread as the answer to being able to select home for the image mapper, but I have done everything just as stated, even the last secondarily added part, and it does not work. I also read somewhere the version 1.4 would have this as an option, and I have 1.4 and it does not. If someone could come up with some code that works or show how the steps on this thread were explained incorrectly, it would be a great thing because many people have posted who would like this as an option.

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 months later...
Hello!
Where exactly did you put this missing text in index.php? Did you put it alone, or along with rocky's text? Thanks!


Hi, here is my complete index.php file
<?php

include(dirname(__FILE__).'/config/config.inc.php');

if(intval(Configuration::get('PS_REWRITING_SETTINGS')) === 1)
   $rewrited_url = __PS_BASE_URI__;

/* CSS ans JS files calls */
$css_files = array(__PS_BASE_URI__.'css/jquery.cluetip.css' => 'all', _THEME_CSS_DIR_.'scenes.css' => 'all');

include(dirname(__FILE__).'/header.php');

$smarty->assign('HOOK_HOME', Module::hookExec('home'));

/* Scenes  (could be externalised to another controler if you need them */
$smarty->assign('scenes', Scene::getScenes(1, intval($cookie->id_lang), true, false));

$smarty->display(_PS_THEME_DIR_.'index.tpl');

include(dirname(__FILE__).'/footer.php');

?>



and whats about themes in index.tpl directory,
should be edited as rocky posts. I've tried what you wrote above, but didn't work for me
Link to comment
Share on other sites

Hello!
Where exactly did you put this missing text in index.php? Did you put it alone, or along with rocky's text? Thanks!


Hi, here is my complete index.php file
<?php

include(dirname(__FILE__).'/config/config.inc.php');

if(intval(Configuration::get('PS_REWRITING_SETTINGS')) === 1)
   $rewrited_url = __PS_BASE_URI__;

/* CSS ans JS files calls */
$css_files = array(__PS_BASE_URI__.'css/jquery.cluetip.css' => 'all', _THEME_CSS_DIR_.'scenes.css' => 'all');

include(dirname(__FILE__).'/header.php');

$smarty->assign('HOOK_HOME', Module::hookExec('home'));

/* Scenes  (could be externalised to another controler if you need them */
$smarty->assign('scenes', Scene::getScenes(1, intval($cookie->id_lang), true, false));

$smarty->display(_PS_THEME_DIR_.'index.tpl');

include(dirname(__FILE__).'/footer.php');

?>



and whats about themes in index.tpl directory,
should be edited as rocky posts. I've tried what you wrote above, but didn't work for me


somebody help me please, i really need this feature :-S i 'm using 1.3.7.0
Link to comment
Share on other sites

  • 3 weeks later...
  • 2 weeks later...
Hello,
anyone came up with a solution for PS 1.4 and above ? Thank you :)


create a new file on overwrite/classes/controllers named IndexController.php

<?php
class IndexController extends IndexControllerCore
{
   public function __construct()
   {
       parent::__construct();
   }

   public function setMedia()
   {
       parent::setMedia();
       Tools::addCSS(array(
           _PS_CSS_DIR_.'jquery.cluetip.css' => 'all',
           _THEME_CSS_DIR_.'scenes.css' => 'all'));
   }

   public function process()
   {
       parent::process();

       self::$smarty->assign('scenes', Scene::getScenes((int)(1), (int)(self::$cookie->id_lang), true, false));
                       /* Scenes images formats */
               if ($sceneImageTypes = ImageType::getImagesTypes('scenes'))
               {
                   foreach ($sceneImageTypes AS $sceneImageType)
                   {
                       if ($sceneImageType['name'] == 'thumb_scene')
                           $thumbSceneImageType = $sceneImageType;
                       elseif ($sceneImageType['name'] == 'large_scene')
                           $largeSceneImageType = $sceneImageType;
                   }
                   self::$smarty->assign('thumbSceneImageType', isset($thumbSceneImageType) ? $thumbSceneImageType : NULL);
                   self::$smarty->assign('largeSceneImageType', isset($largeSceneImageType) ? $largeSceneImageType : NULL);
               }
   }

}



then modify index.tpl

{if $scenes}
       <!-- Scenes -->
       {include file="$tpl_dir./scenes.tpl" scenes=$scenes}
{/if} 
{$HOOK_HOME}



create a scene or image mapping and select you set the homepage checkbox

done!

  • Like 1
Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...
  • 2 weeks later...
  • 2 weeks later...
  • 2 months later...
  • 2 months later...

Found an easy way for mapping frontpage picture:

 

1. Google, download and install arbitrary HTML module

2. Create picture with links (google for tutorials if dunno how)

3. Place arbitrary module on homepage (dont forget to move it to top position of frontpage modules)

4. Upload pictures (the ones you got when creating picture with links)

5. Paste html code (the one you got when creating picture) to arbitrary module placed on homepage

6. Edit html code to get right links to where you uploaded pictures

7. Delete frontpage picture in frontpage editor module

8. Refresh

 

Here you are :)

Link to comment
Share on other sites

  • 3 months later...
  • 4 months later...
  • 3 months later...
  • 1 month later...

Try this in override/controllers/front/IndexController.php. Don't forget to change $this->category->id to your home category id.

 

<?php
class IndexController extends IndexControllerCore
{
public function __construct()
{
 parent::__construct();
}

public function setMedia() {
 parent::setMedia();
 if ($this->context->getMobileDevice() == false)
 {
  //TODO : check why cluetip css is include without js file
  $this->addCSS(array(
   _THEME_CSS_DIR_.'scenes.css' => 'all',
   _THEME_CSS_DIR_.'category.css' => 'all',
   _THEME_CSS_DIR_.'product_list.css' => 'all',
  ));
  if (Configuration::get('PS_COMPARATOR_MAX_ITEM') > 0)
   $this->addJS(_THEME_JS_DIR_.'products-comparison.js');
 }
}

public function process()
{
 parent::process();
 $this->assignScenes(); 
}
/**
 * Assign scenes template vars
 */

protected function assignScenes()
{
 $this->category->id=2;
 // Scenes (could be externalised to another controler if you need them)
 $scenes = Scene::getScenes($this->category->id, $this->context->language->id, true, false);
 $this->context->smarty->assign('scenes', $scenes);

 // Scenes images formats
 if ($scenes && ($sceneImageTypes = ImageType::getImagesTypes('scenes')))
 {
  foreach ($sceneImageTypes as $sceneImageType)
  {
   if ($sceneImageType['name'] == ImageType::getFormatedName('m_scene'))
 $thumbSceneImageType = $sceneImageType;
   elseif ($sceneImageType['name'] == ImageType::getFormatedName('scene'))
   $largeSceneImageType = $sceneImageType;
  }

  $this->context->smarty->assign(array(
 'thumbSceneImageType' => isset($thumbSceneImageType) ? $thumbSceneImageType : null,
 'largeSceneImageType' => isset($largeSceneImageType) ? $largeSceneImageType : null,
  ));
 }
}


}

 

In your index.tpl:

 

{if $scenes}
<!-- Scenes -->
{include file="$tpl_dir./scenes.tpl" scenes=$scenes}
{/if}

  • Like 1
Link to comment
Share on other sites

  • 1 month later...
  • 8 months later...

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