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?

Link to comment
Share on other sites

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" />

Link to comment
Share on other sites

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???

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.