Jump to content

Recommended Posts

Posted

Hey everyone. I have a new Module in the works. It's 99.9% 75% ready for general release, but already running on my own sites for weeks.
[Edit: see post about bug re. 3rd party module]

If you've ever opened /site/templates/ on a project that's been running for a year, you know the feeling. 20-50 PHP with no structure, no grouping - an alphabetical avalanche.
I usually get so far by namespacing all my files, but sometimes I wish for more organisation.

Stemplates lets you organise your templates into folders. That's real directories on the filesystem - the way you're used to working.

So, instead of leaving everything in a flat directory, you can go from this…

site/templates/
├── account-dashboard.php
├── account-billing.php
├── shipping-methods.php
├── shipping-tracking.php
├── blog-index.php
├── blog-post.php
└── blog-category.php

to this…

site/templates/
├── account/
   ├── dashboard.php
   └── billing.php
├── shipping/
   ├── methods.php
   ├── tracking.php
└── blog/
    ├── index.php
    ├── post.php
    └── category.php

I've been running it on my own sites without issues for a while, and it takes just minutes to set up, even on a large site. Setup takes even less time if you're using AI/MCP.

Even better, Stemplates is:

    completely non-destructive
    doesn't touch your database
    doesn't modify your templates or fields
    doesn't change anything in the admin UI
    doesn't alter your workflow
    free from manual aliases, no mapping files, no rewrite rules to maintain
    doesn't touch system templates (admin, repeaters, etc.) 

It also works with page classes and supports nested subfolders (50 levels tested).

Understandably, I was reluctant to mess around with such a fundamental part of my sites, so a few safeguards exist...

  • Migrate one template at a time at your own pace - no big switchover required
  • Your existing flat templates keep working untouched, alongside any you've already moved
  • If a file can't be found in its subfolder, ProcessWire falls back to its normal flat-folder behaviour automatically - the site doesn't break
  • Uninstall cleanly at any time.

Stemplates Free is undergoing a slight rework available now DM me for access.

Stemplates Pro (coming soon) takes Stemplates even further. More soon, but honestly, Stemplates (Free) will take care of 99% of your new template -> folders world.

Thanks for reading!
Peter

 

  • Like 1
  • Peter Knight changed the title to Introducing: Stemplates - template folders
Posted

Caveat 01

For transparency, I should note that the only files presenting issues were include files where the path was not absolute.

The solution was to change:

include("includes/get-widget.inc");


to

include($config->paths->templates . "includes/get-widget.inc");


You need to do this for every include and require that uses a relative path. But, it's a one-time change, and once it's updated, the template location does not matter.

  • Peter Knight changed the title to WIP: Stemplates - template folders
Posted

Well, just to show that life has a sense of humour. After sitting on Stemplates and testing without problems for weeks, literally 1 hour after posting this, I found an issue. It's more a compatibility issue with a popular 3rd party module, really.

Not a huge blocker in itself. It's actually easily fixed manually in the affected module.

But the core premise of Stemplates is that you can install it without editing existing templates, modules, or configuration. So this matters philosophically to me.

The fix is straightforward once you're aware of it, but the danger is you might not be. Everything on the site continues to look completely normal. No errors, no warnings. Something just quietly stops working.

The good news is that Stemplates Pro doesn't suffer the same issue as it uses a different approach.

So I'm going to go back to the drawing board a little and see what I can do for the free version before I push this any further.

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
×
×
  • Create New...