Welcome Guest, Not a member yet? Register   Sign In
Linking to Stylesheets

Try to do what WanWizard suggests.

[quote author="Praveen A P" date="1284875011"][quote author="WanWizard" date="1284862610"]Move your application directory out of the system directory, and move your assets out of your application directory.

Most people use a /assets directory, in there you can create /css, /js and so on. You then create links like this:
<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>assets/css/defaultStyle.css"/>

which makes them independent of your application directory, and because you no longer hardcode your url's, fully portable.[/quote]

Tried the base url thing which did not work. Let me try the other part.[/quote]

Have u config u'r base url properly from u'r config.php file... ?

try this
in your config.php

$config['css_url'] = "http://".$_SERVER['HTTP_HOST'];
$config['css_url'] .= preg_replace('@/+$@','',dirname($_SERVER['SCRIPT_NAME'])).'/css/';

specify the location of the css directory relative to the application root

in your view

<title>Sample Page</title>

<link rel="stylesheet" type="text/css" href="<?php echo $this->config->item('css_url') . 'mystyles.css'; ?>" media="screen" />


another handy trick is to use

$config['base_url'] = "http://".$_SERVER['HTTP_HOST'];
$config['base_url'] .= preg_replace('@/+$@','',dirname($_SERVER['SCRIPT_NAME'])).'/index.php/';

in the config.php so you can rename your root application folder to whatever you want and just rename or move the whole folder and you application will pick up the new location.

it does mean if your using forms you have to use something like

$my_base = base_url();
//$my_action = $my_base . "site/processlistedit";
$my_action = $my_base . "site/messages/edit/" . $id;
echo "<form method='post' action= $my_action />";

// End of table
<tr><td>&lt;input type="submit" value="Submit" /&gt;&lt;/td></tr>

$my_base = base_url();
$my_action = $my_base . 'site/' . $myaction1;
echo "<br/>";
echo "<br/>";
echo "<a href=" . $my_action . " title='Home'>Click Here to return</a>";

it works for me but if you have a better way let us know.

You could use link_tag(): http://ellislab.com/codeigniter/user-gui...l#link_tag

[eluser]Praveen A P[/eluser]
Thanks alot guys for the help.

Theme © iAndrew 2016 - Forum software by © MyBB