Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2018-08-04 17:09:50

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,137
GitHub

CSS URL throws a 404 when referenced from a page

I’m modifying the default Textpattern front-side theme to serve font assets locally. The work-in-progress repo is here if you’d like to examine the code.

My tweaked theme is visually identical to the default theme. I am serving the equivalent Google Fonts CSS and files locally, via the Themes directory:

/themes
  /four-point-seven-no-remote
    /styles
      /fonts
        [font files in here]
      fonts.css

Nothing especially strange, just removing the Google-ness. I have encountered a problem with generating the URL for referencing the fonts.css file I’ve made.

There’s a comment in the default theme code that says: <!-- ...or you can use (faster) external CSS files e.g. <link rel="stylesheet" href="<txp:page_url type="theme_path" />/styles/default.css"> -->

And so, this is my code:

<link rel="stylesheet" href="<txp:page_url type="theme_path" />/styles/fonts.css">

If I use this in a page, this is the URL that’s generated (real URL sanitised):

https://example.com/themes/four-point-seven-no-remote/themes/four-point-seven-no-remote/styles/fonts.css

Note the second themes/four-point-seven-no-remote entry. This doesn’t work (404 error).

However, if I use this same code in an article — but minus the link scaffold…:

<txp:page_url type="theme_path" />/styles/fonts.css

…this is the generated URL:

https://example.com/themes/four-point-seven-no-remote/styles/fonts.css

…which works fine.

I am somewhat confused. What am I doing wrong? Thank you in advance for any feedback, pointers or blunt corrections.

Last edited by gaekwad (2018-08-05 08:00:15)

Offline

#2 2018-08-05 00:21:17

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,079
Website

Re: CSS URL throws a 404 when referenced from a page

Odd. The code works fine here, on a fairly default txp472 install (locally).

Just checking… you probably have done it already…

  • Admin > Preferences > Admin: themes is filled for the “Theme directory” entry?
  • Presentation > Themes, the “four-point-seven-no-remote” is imported ?
  • Presentation > Sections, the theme is assigned to all sections ?
  • Presentation > Pages (and Forms), the theme is selected in the dropdown at the top of the side bar?

And finally, are there any messages in debug mode?


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

#3 2018-08-05 08:06:40

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,137
GitHub

Re: CSS URL throws a 404 when referenced from a page

phiw13 wrote #313258:

Odd. The code works fine here, on a fairly default txp472 install (locally).

That’s good to know – I assume it’s me doing something wrong somewhere!

Just checking… you probably have done it already…

  • Admin > Preferences > Admin: themes is filled for the “Theme directory” entry?
  • Presentation > Themes, the “four-point-seven-no-remote” is imported ?
  • Presentation > Sections, the theme is assigned to all sections ?
  • Presentation > Pages (and Forms), the theme is selected in the dropdown at the top of the side bar?

Confirming all these to be correct.

And finally, are there any messages in debug mode?

None at all.

Thanks Philippe. I’m grateful for your time and attention, I’ll take another look at this later today when I have a bit more available time.

Offline

#4 2018-08-06 11:10:22

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,137
GitHub

Re: CSS URL throws a 404 when referenced from a page

Resolved. Problem exists between keyboard and chair.

Edit: theme now available.

Last edited by gaekwad (2018-08-06 12:06:01)

Offline

Board footer

Powered by FluxBB