Forum

Thread tagged as: Question, Runway

Clean Up Scrap Templates

During the build of the Runway site I've been working on, I've kept multiple versions of various perch/templates/content HTML files while I tried to shoot bugs.

Now I'd like to go through and remove the scrap HTML templates that are unused, but I realized it could be hazardous to data I've already entered if I move/delete the wrong template.

Is there a programmatic way to identify used templates to compare them against the file list? A simple text-editor search for "oldfile.html" doesn't necessarily do the trick if some of your templates are assigned via Perch admin instead of via PHP.

Joel Davies

Joel Davies 0 points

  • 4 years ago

Best to hide them first with an underscore at the beginning of the file name, then perm delete when you know it's no longer needed. If you try to edit something which uses a removed template you will know because there will not be fields to edit.

Robert Ketter said:

Best to hide them first with an underscore at the beginning of the file name

Robert, I assume you mean copy the file you want want to tweak and give the original an underscore? Yeah, that's sounds like a smart way to do it; will have to try that next time.

If I enable debug and just scrape all the debug output for each page, can I assume that output will contain all used templates? Or is that a false assumption?

Yes. In debug all the templates in use will be listed, but if your code uses a different template for output then used for input it won't be listed. Thinking now, perch_content() regions may not show a template in debug since it is served from cache, but easiest way to find out is try :)

R. K

Drew McLellan

Drew McLellan 2638 points
Perch Support

There's no programmatic way to get a list of templates that are, or might be, used. Templates can't be dynamically invoked, so it does require knowledge of how the site is built and used.