samedi 16 mai 2020

If condiction in HTML with URL

I'm trying to do an if condiction in my HTML file in codeigniter that checks the URL and if it contains part of the URL it does one thing if doesnt it does something else

For example:

My URL is

localhost/index.php/cart/galery1

and when I click a photo it applies a filter with this URL

localhost/index.php/cart/galery1/2

the thing is that when I click in a photo after the filter it goes to something like

localhost/index.php/cart/galery1/2/2

There's a way I can do an if condiction checking the URL in my controler or my html ?

My code is something like that right now

HTML

<div id="top-industries" class="gallery">
        <div class="container">
          <h3 class="tittle">As Nossas Casas</h3>
                <div class="gallery-bottom">

                {foreach $products as $product}
                     <div class="view view-ninth">
                       <a href="galery1/{$product.cat_id}" class="b-link-stripe b-animate-go  swipebox"  title="Image Title"><img src="{$product.image}" alt="" class="img-responsive" width="330" height="219" target="_blank">
                        <div class="mask mask-1"></div>
                        <div class="mask mask-2"></div>
                        <div class="content">
                            <h2>CASA 1</h2>
                            <!--<p>A wonderful serenity has taken possession of my entire soul, like these sweet mornings of spring which I enjoy with my whole heart.</p>-->

                        </div></a>
                    </div>
                {/foreach}
                    <div class="clearfix"> </div>
                </div>
        </div>
    </div>

Controler

            if($cat_id){
            $data['catID'] = $cat_id;
            $data['products'] = $this->Cart_model->get_casa($cat_id);
        }
        else{
            $data['products'] = $this->Cart_model->get_products();
        }

Aucun commentaire:

Enregistrer un commentaire