philipnorton42's blog

Bookmarklet To Run XDebug Profiler

Tuesday, February 5, 2013 - 17:24

XDebug is a great PHP debugging tool, but it also comes with a very useful profiler that can tell you all sorts of information about your PHP application. This includes things like memory footprint and CPU load but will also have detailed information about the entire callstack of the code that was run. To enable the profiler part of XDebug you just need to set up a few rules in your xdebug.ini file.
Category: 

Turning Off Drupal CSS and JavaScript Aggregation With Drush

Monday, February 4, 2013 - 15:07

I often find that after recreating a Drupal site locally to do some testing that I have left CSS and JS aggregation turned on. This can be turned off easily enough via the performance page, but this often breaks the flow of what I am doing. As an alternative I use Drush to reset the values via the command line.

The Drush command variable-set can be used to alter any value in the variable table. The two values needed for CSS and JavaScript aggregation are preprocess_css and preprocess_js. To turn these values of we just set them to 0 like this.

Category: 

Uzing Tar To Compress And Uncompress Files

Sunday, February 3, 2013 - 22:13

The tar command can be used to compress or extract one or more files in Linux. A tar file isn't actually a compressed format, instead it is a collection of files within a single file. The tar command can take one or more files, convert them into a tar file and then compress it into a gzip file format. The file created will have the extension tar.gz.

There are a large number of flags that can be used but the main ones for everyday use are.

Category: 

Checking If An Element Exists In jQuery

Sunday, February 3, 2013 - 18:32

To verify that an element exists in the DOM you just need to use the .length property of a jQuery lookup. If the element is there then the number of elements found will be greater than 0.

Category: 

Creating Custom User Admin Actions In Drupal 7 Organic Groups

Saturday, January 26, 2013 - 22:51

Organic Groups (OG) in Drupal 7 has a role based permission system that works on a group by group basis. This permissions system works separately to the main Drupal permission system, which can cause a couple of issues. For example, if you want to give a group role access to give other users roles then you'll need to give them the 'Administer groups' permission. The downside of this is that it overrides Drupal's core permissions to do with node deletion and allows the role to delete the group.

Category: 

Load Drupal Organic Group Role By Name

Wednesday, January 23, 2013 - 17:10

I have been developing a site with the Drupal 7 Organic Groups (OG) module today and I found the need to grab a bunch of users from a group depending on their group role. The first parameter here is the group GID (not the node ID) and the second is an array of role ID's to use.

Category: