Welcome Guest, Not a member yet? Register   Sign In
Problem with loading views properly
#1

[eluser]AntonioAntar[/eluser]
Hello everyone,

So i'm having difficulty loading some views properly and here is what is happening

I have my css,Java and image folders all at the root folder (htdocs since I'm using XAMMP)

I'm working with multiple controllers. My first controller, let's call in main is working nicely and the views are loading up fine

it looks like this

class Main extends CI_Controller {

public function index() {

$this->load->view('home-page');
}
public function blog() {
$this->load->view('blog');
}

public function FAQ() {
$this->load->view('faqs');
}

I have my views in my view file and everything is going well

now I have another controller I'm working with

class Test extends CI_Controller {

public function index() {

$this->load->view('test');
}
public function not_working() {

$this->load->view('not-working');
}

}

the second controller is routed in a way that the url looks like this

localhost: main/test/not working

now, my view is working perfectly for the function test, but for the function not_working, the page views the text but does not display the css and javascript, so the page is fragmented

all my views are in the view file and non of them have any subfolders within the view folder

any idea why my view does not load properly for the pages that follow my index page for the contoller Test?
#2

[eluser]ivantcholakov[/eluser]
Probably you use relative addresses for css, images, and other assets. The additional segments of the web-page address are treated by the browser as directories. You have two options:

1. To make all of your addresses to assets absolute URLs or absolute URIs. For new projects I prefer this way;

2. Or to leave the addresses (to css, image, etc.) relative. Then, at the head section of your pages you need to add base tag:

Code:
<base href="<?php echo base_url(); ?>" />

The relative addresses should be set according to this base URL.
#3

[eluser]gabybob[/eluser]
AntonioAntar

he will be placed in a root supplements directory
root / assets / css
root / assets / images
root / assets.js

...

directories application / views / myview are not explored by CI 3-0-dev for safety reasons possitionner is at the root of CI

best regards
#4

[eluser]AntonioAntar[/eluser]
Thank you friends for the help

I put <base href="<?php echo base_url(); ?>" /> in the head section of my view file and now everything is working like a charm

Best regards
#5

[eluser]gabybob[/eluser]
good evening

see http://ellislab.com/codeigniter/user-gui...elper.html

the <base ..... /> this of HTML ???

sorry,

Gabriel

#6

[eluser]ivantcholakov[/eluser]
@gabybob
Quote:the <base ..... /> this of HTML ???
Yes. It is a standard tag.

There is one inconvenient thing about it. It changes the behavior of links such as
Code:
<a href="#">Click me</a>
.




Theme © iAndrew 2016 - Forum software by © MyBB