Jump to content

One template doesn't recognise any paths, but one works fine


JohnHalsey
 Share

Recommended Posts

I have created 2 templates (so far).  One is for the hompage, it includes files which in turn have links to things like the stylesheet, images etc.  This works fine.  I created a template on PW with this template and created all my editable fields, its all good, page display properly.

I now have a second template as a more basic content page.  I have done the same thing, used the same include files (which is it recognising) but its not happy with the links inside those includes and I can't understand why not.  I uploaded the template to PW in the same way, created my fields, created a page with this template, then when I view the page it shows everything I entered but it doesn't recognise the stylesheet or images etc.

Any suggestions welcome, I'm pulling my hair out.  Man I need a coffee!

FYI I'm using version 2.4.0.

Thanks
John

Link to comment
Share on other sites

Just to add to this it looks like it is happening to all templates that are not set as the home page template.  I just switched the 2 templates over and now the other template works (because the site thinks it is the homepage).

I can't understand why that should make a difference?

Link to comment
Share on other sites

Hi JohnHasley,

Grab a coffee and provide some code please, we can't help without more information :)

If you open your console you should see the resources that won't load. What error code do you get?

Link to comment
Share on other sites

When including your css and js, do you use something like...

<link rel="stylesheet" href="<?php echo $config->urls->templates?>/dist/css/main.css">

...or are you traversing folders like href="../../css/main.css" ?

  • Like 1
Link to comment
Share on other sites

To expand a little on marcus post.


                         the templates folder, usually /site/templates/ (if PW is installed in the root)
                                              |
                             +----------------+------------------+
                             |                                   |
<link rel="stylesheet" href="<?php echo $config->urls->templates?>dist/css/main.css">
                                                                  |    |   |
                                                                  +-+--+-+-+
                                                                   /      \
                                                                  /       custom folder
                                                                 /          named css
                                                           custom folder
                                                            named dist

had 1 slash to much.. changed

Edited by Martijn Geerts
  • Like 1
Link to comment
Share on other sites

Thanks for your replies.
 
I'm not linking to the stylesheet like that.  I'm just doing...
 

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

 This worked for a previous site I did with PW, but I will definitely try that method you have provided.

Link to comment
Share on other sites

site/templates/styles/site.css <-- thats relative, you forget the starting /

So if your url is http://my-domain.com/products/, the browser is gonna look for /products/site/templates/styles/site.css

This should work: ( see the starting slash ? )

<link rel="stylesheet" href="/site/templates/styles/site.css" />
  • Like 1
Link to comment
Share on other sites

site/templates/styles/site.css <-- thats relative, you forget the starting /

And since any new a page is a child page of the home page (/mynewpage/), it will be looking in the wrong place for your css etc

EDIT: Oh, Martijn explained that - I should read the whole post!

Link to comment
Share on other sites

Do you have PW installed in a subdirectory of your html/www root?

If so, then /site etc won't work either. You really should be using:

<link rel="stylesheet" href="<?php echo $config->urls->templates?>/styles/site.css">

like Martijn suggested.

  • 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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...