Jump to content

[SOLVED] slider to assign hook in header part


Recommended Posts

Hi,

I am doing a small slider module in prestashop. It is working fine in site. But the problem is the slider is coming in the home page conent part middle section where the default slider for prestashop comes. I want my slider to show full width(100%) in header part.

My code for slider goes like this

 

For install and hook

 

  


public function install() {
    if (!parent::install() || !$this->installDB() || !$this->registerHook('home') || !$this->registerHook('header'))
      return false;
    return true;
  }

 

For assign hook my code goes like this

 

 


public function hookHome($params) {
    global $cookie, $smarty;
    $value=array();
    $result="SELECT * from "._DB_PREFIX_."slider where status='1'";//To show only enabled images in slider
    $value = Db::getInstance()->ExecuteS($result);
    $result_functions="SELECT * from "._DB_PREFIX_."sliderfuntions";
    $result_row=Db::getInstance()->getRow($result_functions);
    $result_value=$result_row['function_name'];
    $result_height=$result_row['height'];
    $result_width=$result_row['width'];
    $result_navigation = $result_row['navigation'];
    $result_sliderlink = $result_row['slider_link'];
    //print_r($result_sliderlink);
    $smarty->assign('array',$value);
    $smarty->assign('option', $result_value);
    $smarty->assign('result_navigation', $result_navigation);
    $smarty->assign('result_sliderlink', $result_sliderlink);
    if($result_height=="")
    {
      $result_height="300";
    }
    if($result_width=="")
    {
      $result_width="535";
    }
    $smarty->assign('result_height', $result_height);
    $smarty->assign('result_width', $result_width);
    return $this->display(__FILE__, 'myslider.tpl');
}



 public function hookHeader() {
    $this->context->controller->addCSS(($this->_path).'css/styles.css', 'all');
    $this->context->controller->addJS(($this->_path).'js/slider.js', 'all');
  }


 

In myslider.tpl file I am showing my slider.

So can someone kindly tell me how to show the slider in full width(100%). 

 

Link to comment
Share on other sites

just "top"

 

if (!parent::install() || !$this->installDB() || !$this->registerHook('home') || !$this->registerHook('header' || !$this->registerHook('top'))

 

I tried what you said

public function install() {
    if (!parent::install() || !$this->installDB() || !$this->registerHook('home') || !$this->registerHook('header')  || !$this->registerHook('top'))
      return false;
    return true;
  }

But still its showing in the home content section.

Link to comment
Share on other sites

 

I tried what you said

public function install() {
    if (!parent::install() || !$this->installDB() || !$this->registerHook('home') || !$this->registerHook('header')  || !$this->registerHook('top'))
      return false;
    return true;
  }

But still its showing in the home content section.

 

 

Ok got it finally this link helped me finally http://mypresta.eu/en/art/tips-and-tricks/how-to-move-image-slider-module-from-home-to-top-in-prestashop.html

 

I had to use  

public function hookdisplayTop($params){    if ($this->context->getMobileDevice() != false)
return false;
    return $this->display(__FILE__, 'myslider.tpl');
}
Link to comment
Share on other sites

  • 3 months later...

Hello, Vekia

 

I have put my Homeslider to the ' top of pages ' hook...Now,  I want to display it only on Homepage.

I have also tried 

 

{if $page_name == 'index'}

{/if} 

 

at the top of homslider.tpl file on my theme's folder...But, nothing works for me....Plz, help me...

Link to comment
Share on other sites

Thanks for ur reply....

here, is my homeslider.tpl file code....kindly take it into account...

 

{if $page_name == 'index'}
<div id="ot-banner-slideshow" >
<div class="ot-slideshow">
<div class="ot-slideshow-i">
<div class="ot-slideshow-ii">
<!-- Module HomeSlider -->
{if isset($homeslider)}
<script type="text/javascript">
{if isset($homeslider_slides) && $homeslider_slides|@count > 1}
{if $homeslider.loop == 1}
var homeslider_loop = true;
{else}
var homeslider_loop = false;
{/if}
{else}
var homeslider_loop = false;
{/if}
var homeslider_speed = {$homeslider.speed};
var homeslider_pause = {$homeslider.pause};
</script>
{/if}
{if isset($homeslider_slides)}
<ul id="homeslider">
{foreach from=$homeslider_slides item=slide}
{if $slide.active}
<li>
<a href="{$slide.url|escape:'htmlall':'UTF-8'}" title="{$slide.description|escape:'htmlall':'UTF-8'}">
<img src="{$smarty.const._MODULE_DIR_}homeslider/images/{$slide.image|escape:'htmlall':'UTF-8'}" alt="{$slide.legend|escape:'htmlall':'UTF-8'}" height="{$homeslider.height|intval}" width="{$homeslider.width|intval}" />
</a>
</li>
{/if}
{/foreach}
</ul>
{/if}
<!-- /Module HomeSlider -->
</div>
</div>
</div>
</div>
                {/if}
Link to comment
Share on other sites

everything is fine in your code.

it's a part of modules/homeslider/homeslider.tpl file?

if the same file exists in themes/YOUR_THEME/modules/homeslider/homeslider.tpl - you have to modify this file

 

anyway, you can also define exceptions

go to modules -> positions

and near homeslider module (on displayTop modules list, not on displayHeader!) click on edit button

 

then define exceptions, select all available items instead of "index"

Link to comment
Share on other sites

×
×
  • Create New...