Jump to content

Paths in head


Peter Knight
 Share

Recommended Posts

I'm having some problems with css, include and image paths and wondered what the advice was for the location of following

assets (folder in root)

- scripts

- images

- css

Currently I have it in the root but perhaps it should be located in the default site/assets/ directory which comes with PW?

Reason I ask is because I have a templates folder with a homepage and basic-page template located at site/templates.

Both files are located in exactly the same level but both require different paths for the CSS

Homepage only works with

  <link rel="stylesheet" href="assets/scripts/foundation/css/normalize.css">
  <link rel="stylesheet" href="assets/scripts/foundation/css/foundation.css">
  <link rel="stylesheet" href="assets/scripts/foundation/css/foundation-custom.css">
  <link rel="stylesheet" href="assets/css/styles.css">

Basic page only works if I add "../" before above

  <link rel="stylesheet" href="../assets/scripts/foundation/css/normalize.css">
  <link rel="stylesheet" href="../assets/scripts/foundation/css/foundation.css">
  <link rel="stylesheet" href="../assets/scripts/foundation/css/foundation-custom.css">
  <link rel="stylesheet" href="../assets/css/styles.css">

I should probably make the above into a single include but I'd rather solve this mystery first.

Link to comment
Share on other sites

<link rel="stylesheet" href="<?php echo $config->urls->assets; ?>scripts/foundation/css/foundation.css">

Although the convention is to put them under templates/scripts etc, in which case you'd want:

<link rel="stylesheet" href="<?php echo $config->urls->templates; ?>scripts/foundation/css/foundation.css">

This way you will always have the full url to each resource.

You could also just do:

<link rel="stylesheet" href="/site/templates/scripts/foundation/css/foundation.css">

These root relative paths will always work no matter what page you are on.

  • Like 2
Link to comment
Share on other sites

You could also just do:

<link rel="stylesheet" href="/site/templates/scripts/foundation/css/foundation.css">

These root relative paths will always work no matter what page you are on.

That would normally be my own setup. In this instance, it doesn't work. Well, it works for the homepage but any sub-pages dont work.

I suspect my issue is one to do with my shared hosting environment

Because the domain name has yet to be setup, I am working on on a "domain reference" where my hosting company names a folder on a server after the name of my site

IE I have my rewrite based set to

RewriteBase /mysite.com/

But my working homepage (until domain is working) is http://217.199.187.73/mysite.com/

Link to comment
Share on other sites

Your HOMEPAGE and BASIC-PAGE should both be in the same directory.

If they are not, I suggest you put them together. In fact, keep ALL YOUR TEMPLATES TOGETHER.

I see you are using Foundation. Here is what it should look like:

post-609-0-87590600-1409288250_thumb.png

Do not "hard code" the path to your foundation.css file:

<link rel="stylesheet" href="assets/scripts/foundation/css/foundation.css">
Instead, move your foundation folder into the templates folder. Link it like this:
<link rel="stylesheet" href="<?php echo $config->urls->templates; ?>foundation/css/foundation.css" />

Keep your homepage and basic-page together next to the foundation folder.

Make the template folder your only WORKING FOLDER. That was everything is contained in one folder, instead of scattered throughout your site.

post-609-0-08850800-1409288602_thumb.png

I hope I explained it well enough for you.

Let us know if we can help you further.

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...