CodeIgniter Forums
Help! all styles disappear when I go to a different view - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Help! all styles disappear when I go to a different view (/showthread.php?tid=21885)



Help! all styles disappear when I go to a different view - El Forum - 08-24-2009

[eluser]zuluanshee[/eluser]
here is the site:
travelfound.com

press the 'Europe' link at the right (that's teh only one currently configured), you'll see what happens.

the view is mostly the same as the front page.

here si the code

view
Code:
<div class="newsItem">
<h1>Where Do You Want To Go?</h1>
<ul>
<li>&lt;?php echo anchor('continents/','Africa');?&gt;</li>
<li>&lt;?php echo anchor('continents/', 'Asia');?&gt;</li>
<li>&lt;?php echo anchor('continents/index/Europe/', 'Europe');?&gt;</li>
<li>&lt;?php echo anchor('continents/', 'US and Canada');?&gt;</li>
<li>&lt;?php echo anchor('continents/', 'Central America and Caribbean');?&gt;</li>
<li>&lt;?php echo anchor('continents/','South America');?&gt;</li>
<li>&lt;?php echo anchor('continents/','Pacific Rim and Oceania (+Australia & New Zealand)');?&gt;</li>
</ul>
                
</div>
model
Code:
class CountriesModel extends Model
{
    function getCountries($continent)
    {
        $query = $this->db->query("SELECT country_name FROM countries WHERE continent_name = '$continent'");
        //$query = $this->db->where('country_name', $continent);
        
        if($query->num_rows() > 0)
        {    
            foreach($query->result() as $row)
            {
                $data[] = $row;
            }
        }    
        return $data;
    }
}

controller
Code:
class Continents extends Controller
{
    function Continents()
    {
        parent::Controller();
//        $this->load->helper('url');
    }
    
    function index()
    {
        $this->load->model('countriesmodel');
        $continent = $this->uri->segment(3);
        echo "xxx" . $continent;
        $data['countries'] = $this->countriesmodel->getCountries($continent);
        $this->load->view('continentview', $data);
    }    
}



Help! all styles disappear when I go to a different view - El Forum - 08-24-2009

[eluser]davidbehler[/eluser]
I take it that your css folder is outside the system/application folder? Then try using
Code:
&lt;link rel="stylesheet" type="text/css" href="&lt;?php echo base_url().'/css/style.css'; ?&gt;" /&gt;
instead of your relative path.


Help! all styles disappear when I go to a different view - El Forum - 08-24-2009

[eluser]Dam1an[/eluser]
[quote author="waldmeister" date="1251113211"]I take it that your css folder is outside the system/application folder? Then try using
Code:
&lt;link rel="stylesheet" type="text/css" href="&lt;?php echo base_url().'/css/style.css'; ?&gt;" /&gt;
instead of your relative path.[/quote]Actually, base_url includes the '/' at the end, so you'd change it to
Code:
&lt;link rel="stylesheet" type="text/css" href="&lt;?php echo base_url().'css/style.css'; ?&gt;" /&gt;



Help! all styles disappear when I go to a different view - El Forum - 08-24-2009

[eluser]davidbehler[/eluser]
You are right!
For my projects I have rewritten the base_url method to actually take a parameter (similar to site_url) and not have to do the concatination myself Smile


Help! all styles disappear when I go to a different view - El Forum - 08-24-2009

[eluser]zuluanshee[/eluser]
ok i guess it's normal to put in system/applicatin folder. Changing right now


Help! all styles disappear when I go to a different view - El Forum - 08-24-2009

[eluser]zuluanshee[/eluser]
hmm, same problem. Front page is ok but when you click Europe, the styles are still missing.


Help! all styles disappear when I go to a different view - El Forum - 08-24-2009

[eluser]InsiteFX[/eluser]
Try this:

Code:
In head section:

&lt;?php
    echo "\n". link_tag('assets/css/your.css');
?&gt;

This should be in all your html views.

Enjoy
InsiteFX


Help! all styles disappear when I go to a different view - El Forum - 08-24-2009

[eluser]zuluanshee[/eluser]
Bravo! Fixed! Thanks.