We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

New Extension: Templatizer

Development and Programming

tbritton's avatar
tbritton
714 posts
16 years ago
tbritton's avatar tbritton

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.

       
Richard Frank's avatar
Richard Frank
200 posts
16 years ago
Richard Frank's avatar Richard Frank

Thanks; regex is scary at first but extremely powerful; this will be useful for the community.

In terms of “Templatizer”, it would be great if it could generate template groups as well?! Just adding in that feature request ;>)

       
Ingmar Greil's avatar
Ingmar Greil
29,243 posts
16 years ago
Ingmar Greil's avatar Ingmar Greil

Just because you mentioned regular expressions: http://www.smashingmagazine.com/2009/06/01/essential-guide-to-regular-expressions-tools-tutorials-and-resources/

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

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.

       
tbritton's avatar
tbritton
714 posts
16 years ago
tbritton's avatar tbritton

Wow! What a super bunch of resources! I’m bookmarking a bunch of tabs for sure!

Terry

       
matt romaine's avatar
matt romaine
50 posts
16 years ago
matt romaine's avatar matt romaine

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!

       
123454329's avatar
123454329
144 posts
16 years ago
123454329's avatar 123454329

I had the same experience that Chris Clarke made. Not exactly 2,000 but enough to frighten me badly. I wonder why nobody else seems to have the issue of unwanted duplicates being auto-generated …

       
rgbink's avatar
rgbink
63 posts
15 years ago
rgbink's avatar rgbink

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.

       
Avi Block's avatar
Avi Block
27 posts
15 years ago
Avi Block's avatar Avi Block

Templatizer only takes care of getting EE to recognize the template, in other words to get it into the database. Once its in the database, you have to either delete it from the db or from the cp.

       
rgbink's avatar
rgbink
63 posts
15 years ago
rgbink's avatar rgbink
Templatizer only takes care of getting EE to *recognize* the template, in other words to get it into the database. Once its in the database, you have to either delete it from the db or from the cp.

Gotcha. In that case, it works like a charm! 😉

       
Jesse M's avatar
Jesse M
92 posts
15 years ago
Jesse M's avatar Jesse M

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?

       
1 2 3

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.