1

I have a bit of an issue with a project I recently took over using Expression Engine running v2.92 (I think). I'm pretty new to EE so maybe I'm missing something obvious.

The javascript template returns a 404 locally, but works fine on the production server. All the other templates (which are web pages) resolve fine. The database and files were downloaded directly from the production server and modified for my local system.

Things I've tried to no avail.

  • Toggled Strict URL's in Template preferences
  • Made sure the template path is correct for my local system
  • Set the base url in config to my local system url in config/config.php
  • Set the cachedir to my local path in config/database.php
  • Set the proper URL's in Admin -> General Configuration for root and themes
  • Made sure the javascript templates are set to type of JS
  • Checked the template routes, there doesn't appear to be anything here out of the ordinary.

This just doesn't make sense to me, I know it's reading the template files because if I edit one of the web page files directly the edit appears on the local site fine. It just acts like the javascript group doesn't exist at all. Am I missing something very basic here?

code linking the js template, this line lives in the footer of the templates that need this particular js file

<script src="/javascript/products"></script>

folder structure

  • Show us the template code. – Robson Sobral Sep 12 '16 at 20:18
  • It's relatively long code and I'm pretty sure the code is irrelevant since the problem isn't that it doesn't work, the problem is the system can't find it and only locally, the code works fine in production. – Rick Calder Sep 12 '16 at 21:01
  • I just want to see how you're linking to the js file. – Robson Sobral Sep 12 '16 at 21:02
  • Updated the question, it's just a basic link. The javascript.group has two different js files in it. products and product_rates. – Rick Calder Sep 12 '16 at 21:12
  • I also uploaded an image of what that folder looks like, as I said all the other groups there (web pages) resolve fine. – Rick Calder Sep 12 '16 at 21:15
0

I don't know which is the difference between your local and remote environments, but I know that the link works on the remote one just by coincidence.

A src parameter value like /javascript/products points to a products file at a javascript folder on the site root.

If you want to load a template file saved together with all others EECMS templates, you need to use the path variable:

<script src="{path='javascript/products'}"></script>

In case of a css file, you've a specific variable for them:

<link rel="stylesheet" media="all" href="{stylesheet='channel/channel_css'}" />

This is necessary because is a good practice to keep your templates folder inaccessible to direct linking, for security. This way, you can keep it above the root.

Do you accept a suggestion? If your scripts and styles are purely static, put them outside EECMS template structure, for better performance.

| improve this answer | |
  • Thank you for trying, but that made no difference (in fact in view source it returns the exact same path). I actually vaguely remember trying this a few weeks back. Unfortunately this js isn't purely static, it's accessing the database and has a channel entry tag in it. – Rick Calder Sep 12 '16 at 21:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.