codeigniter奇怪的图像路径问题

时间:2012-01-26 21:18:01

标签: image codeigniter path

我正在尝试使用CI进行应用程序。我的问题是,当我加载主页面时,我可以看到我的图像(路径是base_url / controller)。但是,如果我单击其中一个链接(通过controller / function / seg)并从我的数据库中获取查询数据,则图像将变为断开链接(相同的视图页面,但路径现在为“base_url / controller / function / seg”)。我的图像文件夹在应用程序文件夹之外,我不确定发生了什么。感谢您的帮助。

我的代码:控制器:

class Main extends CI_Controller
{

    public $results;

    function __construct ()
    {
        parent::__construct();

        $this->load->model('project_query');
        $this->results=$this->project_query->query();



    }       


    public function index()  //show my main page
    {
        $data['view']='main_page_V';
        $data['result']=$this->results->result();
        $this->load->view('include/template', $data);

    }

    public function search($city='') {   //after user click the link
        $this->results=$this->project_query->query($city);
        $data['view']='main_page_V';
        $data['result']=$this->results->result();
        $this->load->view('include/template', $data);

    }
}

我的观看页面的一部分:

    //this image become broken link after user click the links 
    <div id='title'><img src='images/title.png' title='index Picture'/></div>


    <section>

    //this image become broken link after user click the links 
    <div id='index'><img src='images/title.jpg' title='index Picture'/></div>

    <nav>

        <ul>
            <li id=browser ><a href=#></a>
                <div id='submenu1'>
                    <ul>
                        <li><?= anchor('main/search/salis','City Of Salisbury');?></li>
                        <li><?= anchor('main/search/fruit','City Of Fruitland');?></li>
                        <li><?= anchor('main/search/wicom','Wicomico County');?></li>
                        <li><?= anchor('main/search/other','Other Municipality ');?></li>
                        <li><?= anchor('main/search/all',"Show All (<span class='red'>Long Processing Time</span>)");?></li>
                    </ul>
                </div>
            </li>

            <li id=user_management><a href=#></a></li>
            <li id=log_out><a href=#> </a></li>
        </ul>

    </nav>

我的模特

class project_query extends CI_Model
    {
        #   internal variables


        function __construct()
        {
            parent::__construct();
        }

        public function query($city='salis')
        {
            $this->db->select('job_number,street_number, city ,map, subdivision_project');
            $this->db->like('city',$city);
            $result=$this->db->get('jobs');
            return $result;
        } 


    }

1 个答案:

答案 0 :(得分:1)

如果您每次都要添加base_url,我不得不怀疑您的$ config ['base_url']值是否设置为CI基于该URL上的所有目录关系。