9

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!

aiden87
  • 929
  • 8
  • 25
  • 52

1 Answers1

5

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.

akmozo
  • 9,829
  • 3
  • 28
  • 44
  • thats it. this works. thanks! :). Just one more question. Why does div take longer to load than banner? How can i fix that? – aiden87 Aug 02 '15 at 14:48
  • @fox Sorry, but I don't understand your question ? – akmozo Aug 02 '15 at 14:55
  • if you visit this page ---> http://lrzdravjeinlepota.si/ ...you will see that div displays inside banner...but like after 5 seconds. i'd like it to display the moment page shows up. – aiden87 Aug 02 '15 at 15:05
  • @fox OK, I see it. It's because of your `owl-carousel` which will start playing after 3 seconds as in your js code : `$('#banner0').owlCarousel({ /* .. */ });`, so if you don't need it, remove it ( the carousel ). – akmozo Aug 02 '15 at 15:10