CodeIgniter Forums
css disappears when adding trailing slash to 4th uri... - 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: css disappears when adding trailing slash to 4th uri... (/showthread.php?tid=18278)

Pages: 1 2


css disappears when adding trailing slash to 4th uri... - El Forum - 04-30-2009

[eluser]ramabodhi[/eluser]
Okay I'm using dynamic links to sort the results...
this is what the code works for, and what did work for awhile.... I have no idea why it stopped..

/inventory/view/$username/$sortField/$sortDirection

i can get as far as sortfield ie: inventory/view/someuser/item_age
that will successfully sort by item age..

once i add it to /inventory/view/someuser/item_age/desc
i lose all my css (though the sorting and display work just fine, but my css disappears)..

the results are sorted in my controller by a custom class thusly
Code:
$data['results'] = $this->data->orderBy($results, $sortField, $sortDirection);
$this->load->view('inventory_view', $data);
the orderBy function in the data library is thus
Code:
function orderBy($array, $index, $order)
            {    
                if($order=='asc'){
                    $code = "return strnatcmp(\$a['$index'], \$b['$index']);"; usort($array, create_function('$a,$b', $code)); return $array;
                }elseif($order=='desc'){
                    $code = "return strnatcmp(\$b['$index'], \$a['$index']);"; usort($array, create_function('$a,$b', $code)); return $array;
                }else return $data;
            }
any ideas why my css disappears when i add a fifth uri segment but everything works fine?


css disappears when adding trailing slash to 4th uri... - El Forum - 04-30-2009

[eluser]ramabodhi[/eluser]
update: i'm finding this all over my site, that I can only have a limited number of uri segments or my css disappears. is this supposed to happen?


css disappears when adding trailing slash to 4th uri... - El Forum - 04-30-2009

[eluser]Daniel Moore[/eluser]
Are you using external style sheets and what method are you using to call them if you are? What is your actual code for linking the style sheet?


css disappears when adding trailing slash to 4th uri... - El Forum - 04-30-2009

[eluser]ramabodhi[/eluser]
one external sheet, using dreamweaver template for all views:
Code:
<link href="../www/assets/plain/css/1.css" rel="stylesheet" type="text/css" />



css disappears when adding trailing slash to 4th uri... - El Forum - 04-30-2009

[eluser]Daniel Moore[/eluser]
Ah... You're using a relative path.

I had problems when I tried using a relative path for the CSS once myself in much the same way you are describing.

Assuming the directory you have listed there as "www" is your web root, then might I suggest you change your link reference to:
Code:
<link href="<?php echo base_url();?>/assets/plain/css/1.css" rel="stylesheet" type="text/css" />

See if that helps.


css disappears when adding trailing slash to 4th uri... - El Forum - 04-30-2009

[eluser]ramabodhi[/eluser]
you just made my day Smile


css disappears when adding trailing slash to 4th uri... - El Forum - 05-01-2009

[eluser]JackMeUp[/eluser]
You just made my day too. Plus it's me b-day today!

Dropped in on a google search for a similar problem,
and whammo, problem solved. I noticed the same problem
with image paths too. Switching to absolute paths fixed
that right up as well.

A.


css disappears when adding trailing slash to 4th uri... - El Forum - 05-01-2009

[eluser]TheFuzzy0ne[/eluser]
Happy birthday, and welcome to the CodeIgniter forums! Big Grin


css disappears when adding trailing slash to 4th uri... - El Forum - 05-01-2009

[eluser]Dam1an[/eluser]
The disapearing CSS has caught me out the first time too

All together now
[sing]
Happy birthday to you
Happy birthday to you
Happy birthday dear JackMeUp
Happy birthday to you
[/sing]


css disappears when adding trailing slash to 4th uri... - El Forum - 05-01-2009

[eluser]Daniel Moore[/eluser]
Cool. Glad I could make so many people's day. Just hope I don't make Clint Eastwood's day. Wink

And Happy Birthday, JackMeUp. Welcome.

@Dam1an: You were a little flat when you hit that G. Wink