I follow the MVC model in PHP + JS + HTML + CSS Also, i use CodeIgniter as framework.

I want to know, what do i need to do to redirect to another controller. I am in the Home page of my project.. and when i click "details" (div = prod_details) for a product, what is supposed to be the reference.

For Help, here's my code

MY HOME controller

class ordiDepot extends Controller {
function ordiDepot(){
    parent::Controller();
}
function index(){


    $data['base'] = $this->config->item('base_url');
    $data['css'] = $this->config->item('chemin').'views/style.css';
    $data['image'] = $this->config->item('chemin').'views/images';
    $data['js'] = $this->config->item('chemin').'views/boxOver.js';
    $data['abs'] = 'ordiDepot/accueil';
    $this->load->view('ordiDepotH',$data);
    $this->load->view('ordiDepotB',$data);
    $this->load->view('ordiDepotF',$data);

    }

    function accueil($page){
    $data['details_page'] = $this->config->item($page);
    $data['css'] = $this->config->item('chemin').'views/style.css';
    $this->load->view('details.php',$data);

            }
    }

My VIEW

<div class="left_content">
<div class="title_box">Pieces</div>

    <ul class="left_menu">
        <li class="odd"><a href="services.html">Processeurs</a></li>
        <li class="even"><a href="services.html">Carte Mere</a></li>
        <li class="odd"><a href="services.html">Carte Video</a></li>
        <li class="even"><a href="services.html">Carte Reseau</a></li>
        <li class="odd"><a href="services.html">Bloc d'alimentation</a></li>
        <li class="even"><a href="services.html">Disque dur</a></li>
        <li class="odd"><a href="services.html">Boitiers</a></li>
    </ul> 


 <div class="title_box">Produit en special</div>  
 <div class="border_box">
     <div class="product_title"><a href="details.html">Motorola 156 MX-VL</a></div>
     <div class="product_img"><a href="details.html"><img src= <?php echo $image?>/laptop.png alt="" title="" border="0" /></a></div>
     <div class="prod_price"><span class="reduce">350$</span> <span class="price">270$</span></div>
 </div>  

THANKS TO ALL

 <div class="banner_adds">

 <a href="#"><img src="images/bann2.jpg" alt="" title="" border="0" /></a>
 </div>    

Nouveaux produits

    <div class="prod_box">
        <div class="top_prod_box"></div>
        <div class="center_prod_box">            
             <div class="product_title"><a href="details.html">Motorola 156 MX-VL</a></div>
             <div class="product_img"><a href="details.html"><img src=<?php echo $image?>/laptop.gif alt="" title="" border="0" /></a></div>
             <div class="prod_price"><span class="reduce">350$</span> <span class="price">270$</span></div>                        
        </div>
        <div class="bottom_prod_box"></div>             
        <div class="prod_details_tab">
        <a href="#" title="header=[Add to cart] body=[&nbsp;] fade=[on]"><img src="<?php echo $image;?>/cart.gif" alt="" title="" border="0" class="left_bt" /></a>

        <a href="details.php" class="prod_details">details</a>            
        </div>                     
    </div>



    <div class="prod_box">
        <div class="top_prod_box"></div>
        <div class="center_prod_box">            
             <div class="product_title"><a href="details.html">Ipod</a></div>
             <div class="product_img"><a href="details.html"><img src= <?php echo $image?>/p4.gif alt="" title="" border="0" /></a></div>
             <div class="prod_price"><span class="price">270$</span></div>                        
        </div>
        <div class="bottom_prod_box"></div>             
        <div class="prod_details_tab">
        <a href="#" title="header=[Ajouter panier] body=[&nbsp;] fade=[on]"><img src="<?php echo $image;?>/cart.gif" alt="" title="" border="0" class="left_bt" /></a>

        <a href="details.html" class="prod_details">details</a>             
        </div>                     
    </div>

    <div class="prod_box">
        <div class="top_prod_box"></div>
        <div class="center_prod_box">            
             <div class="product_title"><a href="details.html">Webcam Samsung</a></div>
             <div class="product_img"><a href="details.html"><img src=<?php echo $image?>/p5.gif alt="" title="" border="0" /></a></div>
             <div class="prod_price"><span class="reduce">350$</span> <span class="price">270$</span></div>                        
        </div>
        <div class="bottom_prod_box"></div>             
        <div class="prod_details_tab">
        <a href="#" title="header=[Ajouter panier] body=[&nbsp;] fade=[on]"><img src="<?php echo $image;?>/cart.gif" alt="" title="" border="0" class="left_bt" /></a>

        <a href="details.html" class="prod_details">details</a>            
        </div>                     
    </div> 

    <div class="prod_box">
        <div class="top_prod_box"></div>
        <div class="center_prod_box">            
             <div class="product_title"><a href="<?php echo $abs;?>/details">Motorola 156 MX-VL</a></div>
             <div class="product_img"><a href="details.html"><img src=<?php echo $image?>/laptop.gif alt="" title="" border="0" /></a></div>
             <div class="prod_price"><span class="reduce">350$</span> <span class="price">270$</span></div>                        
        </div>
        <div class="bottom_prod_box"></div>             
        <div class="prod_details_tab">
        <a href="#" title="header=[Ajouter panier] body=[&nbsp;] fade=[on]"><img src="<?php echo $image;?>/cart.gif" alt="" title="" border="0" class="left_bt" /></a>

        <a href="details.html" class="prod_details">details</a>            
        </div>                     
    </div>



    <div class="prod_box">
        <div class="top_prod_box"></div>
        <div class="center_prod_box">            
             <div class="product_title"><a href="details.html">Iphone</a></div>
             <div class="product_img"><a href="details.html"><img src=<?php echo $image?>/p4.gif alt="" title="" border="0" /></a></div>
             <div class="prod_price"><span class="price">270$</span></div>                        
        </div>
        <div class="bottom_prod_box"></div>             
        <div class="prod_details_tab">
        <a href="#" title="header=[Ajouter panier] body=[&nbsp;] fade=[on]"><img src=<?php echo $image;?>/cart.gif alt="" title="" border="0" class="left_bt" /></a>

        <a href="details.html" class="prod_details">details</a>             
        </div>                     
    </div>

    <div class="prod_box">
        <div class="top_prod_box"></div>
        <div class="center_prod_box">            
             <div class="product_title"><a href="details.html">Webcam Samsung</a></div>
             <div class="product_img"><a href="details.html"><img src=<?php echo $image?>/p5.gif alt="" title="" border="0" /></a></div>
             <div class="prod_price"><span class="reduce">350$</span> <span class="price">270$</span></div>                        
        </div>
        <div class="bottom_prod_box"></div>             
        <div class="prod_details_tab">
        <a href="#" title="header=[Ajouter panier] body=[&nbsp;] fade=[on]"><img src= <?php echo $image;?>/cart.gif alt="" title="" border="0" class="left_bt" /></a>

        <a href="details.html" class="prod_details">details</a>            
        </div>                     
    </div> 
Accessoires
    <div class="prod_box">
        <div class="top_prod_box"></div>
        <div class="center_prod_box">            
             <div class="product_title"><a href="details.html">Motorola 156 MX-VL</a></div>
             <div class="product_img"><a href="details.html"><img src= <?php echo $image?>/laptop.gif alt="" title="" border="0" /></a></div>
             <div class="prod_price"><span class="reduce">350$</span> <span class="price">270$</span></div>                        
        </div>
        <div class="bottom_prod_box"></div>             
        <div class="prod_details_tab">
        <a href="#" title="header=[Ajouter panier] body=[&nbsp;] fade=[on]"><img src="<?php echo $image;?>/cart.gif" alt="" title="" border="0" class="left_bt" /></a>

        <a href="details.html" class="prod_details">details</a>            
        </div>                     
    </div>



    <div class="prod_box">
        <div class="top_prod_box"></div>
        <div class="center_prod_box">            
             <div class="product_title"><a href="details.html">Iphone</a></div>
             <div class="product_img"><a href="details.html"><img src=<?php echo $image?>/p4.gif alt="" title="" border="0" /></a></div>
             <div class="prod_price"><span class="price">270$</span></div>                        
        </div>
        <div class="bottom_prod_box"></div>             
        <div class="prod_details_tab">
        <a href="#" title="header=[Ajouter panier] body=[&nbsp;] fade=[on]"><img src="<?php echo $image;?>/cart.gif" alt="" title="" border="0" class="left_bt" /></a>

        <a href="details.html" class="prod_details">details</a>             
        </div>                     
    </div>

    <div class="prod_box">
        <div class="top_prod_box"></div>
        <div class="center_prod_box">            
             <div class="product_title"><a href="details.html">Webcam Samsung</a></div>
             <div class="product_img"><a href="details.html"><img src= <?php echo $image?>/p5.gif alt="" title="" border="0" /></a></div>
             <div class="prod_price"><span class="reduce">350$</span> <span class="price">270$</span></div>                        
        </div>
        <div class="bottom_prod_box"></div>             
        <div class="prod_details_tab">
        <a href="#" title="header=[Ajouter panier body=[&nbsp;] fade=[on]"><img src= <?php echo $image;?>/cart.gif alt="" title="" border="0" class="left_bt" /></a>

        <a href="details.html" class="prod_details">details</a>            
        </div>                     
    </div> 

Shopping cart

        <div class="cart_details">
        3 items <br />
        <span class="border_cart"></span>
        Total: <span class="price">350$</span>
        </div>

        <div class="cart_icon"><a href="#" title="header=[Au panier] body=[&nbsp;] fade=[on]"><img src= <?php echo $image;?>/shoppingcart.png alt="" title="" width="48" height="48" border="0" /></a></div>

    </div>


 <div class="title_box">Nouveaux</div>  
 <div class="border_box">
     <div class="product_title"><a href="details.html">Motorola 156 MX-VL</a></div>
     <div class="product_img"><a href="details.html"><img src= <?php                           echo          $image?>/p2.gif alt="" title="" border="0" /></a></div>
     <div class="prod_price"><span class="reduce">350$</span> <span class="price">270$</span></div>
 </div>  



<div class="title_box">Logiciels</div>

    <ul class="left_menu">
        <li class="odd"><a href="services.html">Jeux</a></li>
        <li class="even"><a href="services.html">Utilitaires</a></li>
        <li class="odd"><a href="services.html">OS</a></li>
    </ul>      

 <div class="banner_adds">

 <a href="#"><img src=<?php echo $image?>/bann1.jpg alt="" title="" border="0" /></a>
 </div>        

有帮助吗?

解决方案

Well to redirect to another controller you just put that controllers URL path as the href of the anchor.

<a href="/controller/action"></a>

Example for a product description page:

<a href="/products/item/324235">Product</a>

Where 324235 is any given product number that needs to be injected into the href from your server side code.

Sorry I didn't look right through your code, so your controller and action names may be different.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top