Hi,

I have been doing alot of drupal sites lately and I use alot of regex to hack alot of the things before they get processed. This avoids alot of modifying of code on the template.php side. But I am not sure if this is bad for loading times as the preg_replace function gets run everytime the page comes up... But either way preg_replace on the tpl pages saves alot of time instead of theming the functions. Do many of you do it this way too?

thx

Comments

dvessel’s picture

I doubt many would take this approach. It's harder to read the code and it can reduce performance depending on how extensively it is used. Certain theming functions can loop many times per page load and doing that on the wrong theming hook can produce a noticeable slowdown.

If it's for your personal projects and you can handle it, then go for it but using regex like you are for clients would be a huge mistake. Your in-effect creating vendor lock-in to a degree. Anyone else taking a look at the code will more than likely be stuck since regex is not often used by theme devs.

joon park