Quick Tips

Var dumping on a live site

I often get contacted by someone that needs something worked out quickly on a live Drupal site. Diagnosing problems and altering theming code often requires lots of var dumping to come up with a solution.
This is fine on a development server or an inactive site but I recently had to do this on a very active site.
(Assuming I'm logged in with uid 1
<?php
if ($user->uid == 1) {
    var_dump($node);
}
?>
 

Unknown modifier 'p'

Suddenly started receiving this error: (preg_replace() [<a href='function.preg-replace'>function.preg-replace</a>]: Unknown modifier 'p') whenever creating a new entry. Also that alias was not creating leaving it as node/id.
Searches blamed it on fckeditor being enabled on certain fields but I did not see fckeditor in use on the page. It was in a collapsed fieldset and disabling it on *pathauto* fixed it.

Do not use Google Analytics on admin pages

In the footer of my tpl files I have Google Analytics, but do not want stats tracked for my admin pages.

<?
// I could also change this to if ($user->uid !=1)
//Or do some sort of role check to keep analytics from loading for me in general

if (arg(0)!="admin"){
?>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("your-ua-code");
pageTracker._trackPageview();
} catch(err) {}</script>
<?}?>