Jump to content

define directories for images, css and js.


yahelarmster

Recommended Posts

Hello there!

 

Okay, i'm really new to php but i love it, right now i want to make a configure.php file that holds the directories for css, js, and links & stuff like in oscommerce:

 

define ('DIR_STYLES' , 'styles/');

 

and lets say that i want to call the styles directory when i declare a stylesheet like so:

<link rel="stylesheet" href="<?php howDoICallIt... ;?>" type="text/css" />

 

could you helpe me with this?

A constant is pretty much just like variable - just without the dollar sign. Just echo it out. But in your example you didn't provide the file name.

<link rel="stylesheet" href="<?php echo DIR_STYLES . 'name_of_css_file.css'; ?>" type="text/css" />

 

or

 

<link rel="stylesheet" href="<?php echo DIR_STYLES; ?>name_of_css_file.css" type="text/css" />

oh yes yes, thanks, so, i'm using an index.php that holds the whole controller, and when someone clicks the submit button or click a <a href="?add" ... > the controller will handle it, then include a form.

i want to have a configure.php file with images, js, css and stuff directories defined, so let's say that i want to do this:

 

... index.php excerpt:

... if (isset($_GET['addform']))

{

  buncha' code...

include 'form.html.php';

exit();

}

 

configure excerpt:

define ('DIR_STYLES', 'styles/');

define ('DIR_IMAGES', 'images/');

etc...

 

and then on the form.html.php call the style like:

 

<link rel="stylesheet" href="<?php echo DIR_STYLES . 'main.css'; ?>" type="text/css" />

 

so, with all that info, do you think it will work???

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.