0

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.

4
  • 1
    Is it loading the 404 Page not Found? Or are you styling a 404 page? Commented Oct 22, 2013 at 4:33
  • @Chitowns24 its a 404 Page not Found on my css Commented Oct 22, 2013 at 4:34
  • check your CSS file path. Commented Oct 22, 2013 at 4:35
  • @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. Commented Oct 22, 2013 at 4:42

3 Answers 3

2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

-1

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.

2 Comments

A wrong css background path won't trigger CI's 404 page though
yes he is also asking for the correct path of the css/image. I included also the view2 page to check if it is existing already on the views folder

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.