0
votes

I'm trying to load a view from my controller using Codeigniter.I made the index page a form then submits it to a different controller. It should show the view after some condition statements but when the view loads the usual CSS has been changed.

Original

 body { 
     background-image: url("/images/layouts/body-bg.gif");
     background-repeat: repeat; 
     font-family: "Montserrat", Arial,sans-serif; 
     color: #404041; 
     line-height: 18px; 
     font-size: 12px;
     font-size: 0.75rem; 
     text-shadow: 0 0 1px rgba(64, 64, 65, 0.2); 
 }

The css being loaded

<!DOCTYPE html>
<html lang="en">
<head>
<title>404 Page Not Found</title>
<style type="text/css">
::selection{ background-color: #E13300; color: white; }
::moz-selection{ background-color: #E13300; color: white; }
::webkit-selection{ background-color: #E13300; color: white; } 

I have no idea why this is happening, the way I load my view in my controller is:

if(//condition)
{
$this->load->view('view_2');
}

Is there a way to stop my css from loading with the html error? I am using Codeigniter 2.1.4 with default settings.

3
Is it loading the 404 Page not Found? Or are you styling a 404 page? - Chitowns24
@Chitowns24 its a 404 Page not Found on my css - marchemike
check your CSS file path. - Suresh Kamrushi
@SureshKamrushi how do I find out if the href link is correct? It's the same view, but when it first loads, the css is fine, then if I call it again, its no longer working. - marchemike

3 Answers

2
votes

the css you see is codeigniter's css for the 404 page - it's telling you that 'view_2' cannot be found

I'll bet you a beer that 'application/views/view_2.php' does not exist. That, or there is another problem in your controller.

This may help: http://ellislab.com/codeigniter/user-guide/tutorial/static_pages.html

Or, please post your entire controller.

0
votes

What i would suggest you is reference your css file(s) with base_url() enabled as that will make sure that the correct file is called irrespective of your current URL.

For Example :

<link href="<?php echo base_url(); ?>your/path_for/cssfile.css" rel="stylesheet" /> 

Let me know if it solves your issue or need more help.

Thanks & Regards,

Zeeshan

-1
votes

Please correct your path to body { background-image: url("../images/layouts/body-bg.gif");. If not found try to copy and paste the absolute path on your browser. sample http://{ip}/{system}/images/layouts/body-bg.gif. Also check if the view2 page is existing on your views folder.