我无法加载请求的文件错误site is visited。作为显示的第一页的产品显示上述错误,以及所有与产品相关的功能,例如产品细节和产品类别。
以下是我的产品类,其中显示了获取所有产品,产品详细信息和类别的方法。
defined('BASEPATH') OR exit('No direct script access allowed');
class Products extends CI_Controller {
public function index()
{
// Get all products
$data['products'] = $this->Product_model->get_products();
// Load View
$data['main_content'] = 'products';
$this->load->view('layouts/main',$data);
}
public function details($id)
{
// Get all products details
$data['product'] = $this->Product_model->get_product_details($id);
// Load View
$data['main_content'] = 'details';
$this->load->view('layouts/main',$data);
}
public function category($id)
{
// Get all products details
$data['products'] = $this->Product_model->get_category_details($id);
// Load View
$data['main_content'] = 'category';
$this->load->view('layouts/main',$data);
}
}
以下是产品视图
<?php if($this->session->flashdata('registered')) : ?>
<div class="alert alert-success panel-body">
<?php echo $this->session->flashdata('registered');?>
</div>
<?php endif;?>
<?php if($this->session->flashdata('pass_login')) : ?>
<div class="alert alert-success panel-body">
<?php echo $this->session->flashdata('pass_login');?>
</div>
<?php endif;?>
<?php if($this->session->flashdata('fail_login')) : ?>
<div class="alert alert-danger panel-body">
<?php echo $this->session->flashdata('fail_login');?>
</div>
<?php endif;?>
<?php foreach($products as $product): ?>
<div class="col-md-4 game">
<div class="game-price"> <?php echo $product->price;?></div>
<a href="<?php echo base_url();?>products/details/<?php echo $product->id;?>">
<img src=" <?php echo base_url();?>assets/images/products/<?php echo $product->image;?>" />
</a>
<div class="game-title">
<?php echo $product->title;?>
</div>
<div class="game-add">
<form method="post" action="<?php echo base_url();?>cart/add">
QTY:<input class="qty" type="text" name="qty" value="1"/><br>
<input type="hidden" name="item_number" value="<?php echo $product->id;?>"/>
<input type="hidden" name="price" value="<?php echo $product->price;?>"/>
<input type="hidden" name="title" value="<?php echo $product->title;?>"/>
<button class="btn btn-primary" type="submit">Add To Cart</button>
</form>
</div>
</div>
<?php endforeach ?>
这是我的视图文件夹结构
答案 0 :(得分:1)
我看到你的视图文件是大写的Category.php。
控制器上有
public function category($id)
{
// Get all products details
$data['products'] = $this->Product_model->get_category_details($id);
// Load View
$data['main_content'] = 'Category'; // match filename
$this->load->view('layouts/main',$data);
}
答案 1 :(得分:0)
确保正确加载视图。 您可以与我们分享您的意见文件夹结构以查找此问题