无法加载请求的文件:category.php [英] Unable to load the requested file: category.php

查看:66
本文介绍了无法加载请求的文件:category.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当访问

解决方案

我看到您的视图文件带有大写的Category.php。



在控制器上有

 公共功能类别($ id) 
{
//获取所有产品详细信息
$ data ['products'] = $ this-> Product_model-> get_category_details($ id);

//加载视图
$ data [’main_content’] =‘Category’; //匹配文件名
$ this-> load-> view(’layouts / main’,$ data);
}


I have the unable to load the requested file error When the site is visited. The product which is the first page to be displayed shows the above error so as all product related functions like the product details and the product category respectively.

Below is my products class showing the method that gets all the product, product details and categories.

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);
}   
}

And below is the Product View

    <?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 ?>

Here's my view folder structure

解决方案

I see you have your view file with upper case Category.php.

There for on controller

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);
}   

这篇关于无法加载请求的文件:category.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆