ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Saving Templates as Text Files — Expected Behavior, or Environmental Problem

March 15, 2012 4:24pm

Subscribe [3]
  • #1 / Mar 15, 2012 4:24pm

    Douglas Back

    19 posts

    This morning I started to set up a site with templates saved as text files. I’m running into an issue where ExpressionEngine does not appear to recognize new template files until either the Template Manager is loaded in the Control Panel, or the templates are synchronized. I’m wondering if this is expected behavior, or if there’s something else going on here.

    Let me give you an example.

    If I have a template group named “hello-world” and within that group, “index.html” as a template, I can make changes to that template and they are reflected after refreshing the outputted page.

    But if I were to go and create new template file (in my file system), say “test.html” in the hello-world.group directory, EE doesn’t appear to realize that’s a valid template until:

    1) Loading the “Template Manager” page in the EE control panel — after loading this page and selecting the ‘hello-world’ template group, the newly created ‘test’ template appears in the list of templates, and EE renders hello-world/test as you would expect.

    2) Synchronizing templates — after syncing the templates, the page renders as you would expect at hello-world/test.

    I’ve checked permissions with what’s indicated in the docs, and they’re looking ok (777 on the template group directories).

    So, is this expected behavior, a bug, or perhaps an environmental problem on my machine?

  • #2 / Mar 16, 2012 2:32pm

    Dan Decker

    7338 posts

    Hi Douglas,

    Let me try to clear this up a bit.

    But if I were to go and create new template file (in my file system), say “test.html” in the hello-world.group directory, EE doesn’t appear to realize that’s a valid template until:

    1) Loading the “Template Manager” page in the EE control panel — after loading this page and selecting the ‘hello-world’ template group, the newly created ‘test’ template appears in the list of templates, and EE renders hello-world/test as you would expect.

    2) Synchronizing templates — after syncing the templates, the page renders as you would expect at hello-world/test.

    What you are experiencing is expected behavior. You may certainly create new templates-as-file outside of the Template Manager. The caveat is that ExpressionEngine has no way of knowing new files exist until you perform either of the actions you mentioned.

    Does that help clarify the issue for you?

    Cheers,

  • #3 / Mar 16, 2012 5:55pm

    Douglas Back

    19 posts

    Hey Dan,

    Thanks for the reply. Definitely cleared it up. The only reason I wrote in was because a colleague is experiencing different behavior on his own install — they’re both local installations for development, and the only difference I can find is that we’re running different versions of Mac OS X (I’m on Lion, he’s on Snow Leopard). Any explanation for why he’s seeing the templates appear without having to load the Template Manager or sync templates?

  • #4 / Mar 19, 2012 12:57pm

    Shane Eckert

    7174 posts

    Hey Douglas,

    That is odd, I am not sure why your colleague is observing a different behavior.

    You might ask your colleague to run through his procedure, he might be inadvertently doing something that does sync up templates.

    Is there anything else I can help you with?

    Cheers,

  • #5 / Mar 27, 2012 10:31pm

    Cameron Corda

    31 posts

    Shane, I asked this question on Twitter, and former EllisLabber Derek Allard chimed in saying:

    “in my experience once it’s setup you’re set. i’ve never synched a thing after that.”
    https://twitter.com/#!/ccorda/status/184802594869358592

    I went back and monitored the templates table on each click:

    1) Create a new template called ‘test.html’ inside of content.group.  No DB change.
    2) Go to /content/test.  The contents of content/index are returned, not my test template.  No DB change.
    3) Login to EE CP at /admin.php.  No DB change.
    4) Go to the template manager.  Click on content, test template is there.  Looking at the DB, there is now a row for this template.
    5) /content/test is now accessible in browser.

    So it looks like something in Step 4 caused the DB to pick up the changes.  This didn’t have anything to do with hitting synchronize templates.

    Looking at libraries/Template.php, it looks like there is a function _create_from_file() to check the filesytem when a template isn’t found in the DB.

    I believe this should be called in the parse_template_uri() function when you load any URL, but it doesn’t seem to be.

  • #6 / Apr 02, 2012 3:15pm

    Dan Decker

    7338 posts

    Hi Cameron,

    Indeed, one of the triggers for “syncing” the files/database is loading the Template Manager. Your experience seems to bear this out.

    We appreciate your suggestion for a additional place to make the call, feel free to submit that as a Feature Request!

    Cheers,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases