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

[eluser]pbreit[/eluser]
Try to do what WanWizard suggests.
#12

[eluser]mi6crazyheart[/eluser]
[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:
Code:
<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... ?
#13

[eluser]daniel9201[/eluser]
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

<head>
<title>Sample Page</title>

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



</head>

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

<?php
$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>
</table>
&lt;/form&gt;

&lt;?php
$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>";
?&gt;

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

[eluser]Vega[/eluser]
You could use link_tag(): http://ellislab.com/codeigniter/user-gui...l#link_tag
#15

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




Theme © iAndrew 2016 - Forum software by © MyBB