Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to display div inside 1 banner - opencart

I'm using opencart for developing my own webstore.

I have 2 banners a.k.a 2 images, first shows product on sale, and second 1 shows contact number.

Now i want to create div inside first banner, which will include a link to other website, so users can press on it...

But when i put div inside my module/banner.tpl and refresh website, div displays inside both banners, instead of just first one.

What am i doing wrong and can some1 help me please?

Here is the code

<div id="banner<?php echo $module; ?>" class="owl-carousel">
   <?php foreach ($banners as $banner) { ?>
   <div class="item">

     <?php if ($banner['link']) { ?>
     <a href="<?php echo $banner['link']; ?>"><img src="<?php echo     $banner['image']; ?>" alt="<?php echo $banner['title']; ?>" class="img-  responsive" /></a>
     <?php } else { ?>

     <img src="<?php echo $banner['image']; ?>" alt="<?php echo  $banner['title'];   ?>" class="img-responsive" />
     <?php } ?>
     </div>

     <div id="gumbek">Nakupujte zdaj!</div>
     <?php } ?>
</div>

<script type="text/javascript"><!--
    $('#banner<?php echo $module; ?>').owlCarousel({
        items: 6,
        autoPlay: 3000,
        singleItem: true,
        navigation: false,
        pagination: false,
        transitionStyle: 'none'
});
--></script>

div id="gumbek"Nakupujte zdaj! ---> is the div i'm talking about

I will appreciate any input. Thank you!

like image 377
aiden87 Avatar asked Jul 31 '15 10:07

aiden87


1 Answers

You can also use a boolean like this :

<?php
    $show_shop_now = TRUE;  
?>

<div id="banner<?php echo $module; ?>" class="owl-carousel">
<?php foreach ($banners as $banner) { ?>
    <div class="item">  
    <?php           
        $img = '<img src="'.$banner['image'].'" alt="'.$banner['title'].'" class="img-responsive" />';

        if ($banner['link']) { 
            $img = '<a href="'.$banner['link'].'">'.$img.'</a>';
        }

        echo $img;
    ?>
    </div>

    <?php 
        if($show_shop_now){ 
            $show_shop_now = FALSE;
    ?>
        <div id="gumbek">Nakupujte zdaj!</div>
    <?php } ?>

<?php } ?>
</div>

Hope that can help.

like image 69
akmozo Avatar answered Oct 05 '22 21:10

akmozo