BTW - not to knock the awesome search and replace power native to EE’s control panel (Utilities/Find and Replace), but I am now a Regular Expressions nut, and Dreamweaver, e-texteditor and others allow you to use Regular Expressions (or RegEx) in search queries.
You can find a great video tutorial and cheat-sheet for Regular Expressions at the e-texteditor.com website.
For instance, if I want to strip all the old PHP out of a page, two of these alone pull just about everything.
\(\<\?php.*?\?\>\)
Will pull all inside parentheses, including the parentheses (do first)( *? makes “not greedy”)
\<\?php.*?\?\>
Will pull all the rest (both used in removing old GoLive 6 dynamic content tags from a site, for example).
Or find both using the either/or vertical pipe character |
\<\?php.*?\?\>|\(\<\?php.*?\?\>\)
You could pare this down even further simply by making the search for the Parentheses “non-greedy” by adding the question mark afterwards (this does exactly the same as the combination above):
\(?\<\?php.*?\?\>\)?
To pull old GoLive 6 <agl:container> opening and closing tags:
\<agl\:container\>
\<\/agl\:container\>
Or find both using the either/or | pipe:
\<agl\:container\>|\<\/agl\:container\>
To pull just about everything GoLive 6 off of a page, then, you could use this super RegEx that also uses /s*? to un-greedily remove unsightly white spaces around the PHP tags:
\<agl\:container\>|\<\/agl\:container\>|\s*?\(?\<\?php.*?\?\>\)?\s*?
(This recently saved me from making 7,165 manual edits to an extensive set of 7 forms that were being converted over to instead use Form Tools, as GL6 dynamic content stuff broke with PHP5, it seems.)
So, another great reason to use templates and an external editor having Regular Expressions capabilities!
Terry Leigh Britton
PS - made this into a Wiki entry here if anyone wants to bookmark that this info.
Just because you mentioned regular expressions: http://www.smashingmagazine.com/2009/06/01/essential-guide-to-regular-expressions-tools-tutorials-and-resources/
Another one which I’ve always referred to when I have the need is http://www.regular-expressions.info/. A really helpful one that. Also Regular Expression Library and RegexAdvice are very very helpful too.
There you are you most-desired extension!!
I’ve been looking for just this kind of functionality for over a year! I don’t know what the most common deployment process is, but for most clients I set up two installs of EE - one for internal previewing, and the officially live one - and whenever new templates, etc. must be added, we create and test on the staging server first. Once that’s all good, I deploy using git on the live server. Until now, that’s also meant having to create each new template via the CP; now, no more!
Thanks!
Nothing like posting after a 9 month lull…
Here’s my test:
Duplicate a template file via FTP Visit the template page Check the CP to see that the template’s in the DB (it is!)
All ok so far.
Delete template file via FTP. Visit template page. Weirdness with lots of n’s. Clear all EE caches. Try again. Weirdness again.
Seems that the only way for the template to be truly gone is to delete it from the CP manually.
I thought, from previous posts, that all I needed to do was delete the file and it would be gone.
Any ideas on the strange n’s? Odd, that.
I thought about creating something like this, but what I had in mind was a way to store all of the settings (e.g. caching, allow PHP, access restrictions, etc.) in the template file or a companion file so that a template could be deleted when not necessary, and restored with all settings intact if needed again later just by putting the template file(s) back on the server. Does this solution do that?
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.