28{/layout:set} Can’t Get a Template to Load from File{/layout:set}

Can’t Get a Template to Load from File

EE Insists on loading from the database

If, like us, you prefer editing your templates using a text editor then it can get frustrating if EE then insists on only loading templates from the database and ignores our carefully crafted files.

When you navigate to your templates in the CP via Design -> Templates -> Template Manager and then select one of your templates you'll see that EE displays "from database" above the template code.

There are two posible problems which have affected us:

1. The templates path is incorrectly set.

Navigate to Design -> Templates -> Global Preferences and check the value of "Server path to site's templates". Now we like to set this to a relative path so that we can move databases easily between dev, staging and live. However for some reason this just doesn't work every time (we suspect it may be related to the version of EE in use). Try putting in the full server path to the templates durectory.

If you're on Windows then you can put in the full server path using forward rather than back slashes. if you use back slashes EE will replace them with forward slashes anyway. The good news is that Windows doesn't mind which way your slashes point.

2. Check the Template File's Time Stamp

We ran in to this one after a lot of head scratching and swearing that our template path was correct. If the time stamp on the template file is older than the time stamp in the database then EE will load the template from the database. Edit and re-save the file. Also, beware of FTP software which stamps files with an incorrect time - ours was an hour out with the server time when we had this problem.

Another issue with FTP is that you can configure your FTP client to preserve the dates and times of the files you upload. If your FTP software is set to do this then it is possible that your uploaded files won't be date stamped with the date and time of upload and will display the date and time of your last edit instead.

Merlin engine logo

The data revolution is here.

Merlin THE API builder for developers. Test it now

Get VIP access