Blogs

OpenCamp was a HUGE success

File 39OpenCamp (with DrupalCamp Dallas 2010) was this past weekend and all indications are that it was a tremendous success.  We worked long and hard putting it together.  We featured 30 Drupal sessions and nearly 100 sessions in all.  Over 600 people attended the Camp.  We had a spectacular evening pyrotechnic jump by the Army Golden Knights.  We had parties Fri and Sat night with live musical entertainment.  We gave away thousands of dollars in various prizes.

A few of us Dallas Drupal cyclists were able to take Jay Batson, the co-founder of Acquia out for a couple laps around White Rock lake (and why didn't we take a picture - Jay was wearing Drupal bikle shorts and jersey!).  All in all it was a great weekend.

Check out the Flickr pool for pictures from OpenCamp (some of them are from the photography contest).  And look for DrupalCamp 2011 sometime this spring.

OpenCamp in Dallas

File 32 Tarakan Design is proud to help bring OpenCamp to Dallas on Aug 27-29, 2010.  It's a new idea in community-driven camps, bring developers and users of Drupal, Wordpress and Joomla! together, as well as those involved in community building, social media and podcasting. Tarakan help put together DrupalCamp Dallas last year, and it was a huge success.

 

File 33We're going to have some great Drupal, Wordpress, Joomla!, and social & new media speakers there, as well as local community experts in various areas of Drupal there to give sessions and help answer questions.  We have an incredible venue - the Crowne Plaza in Addison.  We have a dozen rooms dedicated to the camp.

Well-known Geek Girl and OpenCamp co-organizer Cali Lewis (of geekbrief.tv) was shooting videos at the Crowne Plaza on Sunday- be sure to check the OpenCamp site soon for those videos and lots of pictures.

And sign up soon- it's only $99 until June 1, then it goes up.  That includes everything, include breakfast and lunch each day.   Reserve a room for the weekend too- we have great parties planned for both nights, with live entertainment.

Quick and Easy "Or Admin" Filter for Views

Prerequisites: Drupal 6, Views2, PHP

Recently, we had the need to create an Organic Groups view that filtered nodes based on group membership or, if the current user was admin, to show nodes from all groups.  We needed something like the "Published Or Admin" node filter, only applied to Organic Groups membership.

My first instinct was, "No problem! Organic Groups considers users with the administer nodes permission to be members of all groups." Unfortunately, this membership test does not apply to Views filters.

My second instinct was, "That's OK, we'll just use the user:roles filter". Unfortunately, the user:roles filter acts on the node owner rather the current user.

Contribs to the Rescue

Fortunately, there is a simple way around this using the contribs Views Or and Views PHP Filter. As you are probably aware, views filters are normally combined with logical ANDs, meaning that a node is included only if it satisfies the requirements of all the included filters. Views Or allows us to combine arbitrary filters with logical ORs instead, giving us a lot more flexibility.

Views PHP Filter allows us to execute arbitrary PHP code and return a list of node IDs as either an inclusive or an exclusive filter. For example, if you define a PHP filter that returns the nids (1, 2, 3) and then add a node:published filter, you'd get any of nodes 1, 2, and 3 that are also published. Of course, that wouldn't be particularly useful; however, since we can execute arbitrary PHP we can write some code that does this:

if (the current user is admin) then return (a list of all node ids), otherwise return nothing.

Combine that with Views Or and things start to get interesting. One fortunate thing is that if you have a null clause (like our "return nothing" case), Views Or does not generate anything in the resulting query.

Combining Views PHP Filter and Views Or

With that combination we can effectively get this kind of filter logic: 

If the current user is not admin: if (the current user is a member of the node's group) ← no OR clause since we returned nothing

If the current user is admin: if (the current user is a member of the node's group OR the nid is IN (set of all nids))

Now the problem with this approach is that it incurs an extra database call every time the page is viewed (to get a list of all nids), plus the set of all nids could potentially get really large. If you remember, though, we can configure our PHP filter to be exclusive instead of inclusive.

Using Negative Logic

Now, armed also with the knowledge that nids start at 1, we use negative logic for our PHP code:

if (the current user is admin) then return (nid 0) 

or

global $user;
if (in_array('admin', $user->roles)) {
  return array(0);
}

You see where I'm going with this. Combined with the exclusive PHP filter option, we're saying "nodes that do not have nid = 0", which is to say, all nodes in the system.

File 30

So we end up with the following filters (of course, substitute your own node type):

File 31

 That's it. With just a few lines of code and a couple of modules, you've created an "Or Admin" filter.

 

Improving Drupal Performance (from the Dallas Drupal Feb meeting)

Dallas DrupalAt last night's Dallas Drupal meeting, Dustin Currie of LevelTen Interactive and Mark Sonnabaum of allplayers.com each gave excellent presentations on improving performance of Drupal websites.  I thought I'd briefly recap some of their points here. Most of these tips only apply to production websites, not development.

General Performance Tips

  1. Simply turn on page cache, page compression, and block cache. Block cache isn't available if modules defining content access restrictions are enabled. Look for these settings in admin/settings/performance (D6).
  2. If using Apache, enable mod_deflate and you can see an 80% reduction in the size of output from Apache. You'll also need to add some output filters. There are lots of options as well as caveats, but it is worth exploring and learning.
  3. Aggregate CSS & Javascript. This greatly reduces the number of individual requests made to the webserver. It won't work if you are using Drupal's private files system.  admin/settings/performance (D6).
  4. Use mod_expires and Drupal will send out expires HTTP headers, causing the browser to cache all static files. The setting in the default .htaccess file that installs with Drupal is set for two weeks.
  5. Use a PHP accelerator, such as eAccelerator, APC, or Zend.  Compiled PHP runs much faster. Also of interest is Facebook's accelerator, HipHop.
  6. Use a CDN (Content Delivery Network) to parallelize HTTP requests.  Coming soon- a CDN module for Drupal will make that easier.
  7. Up-and-coming - use Data URIs, which encodes content inline, removing some HTTP requests.  Not well supported yet- esp in IE6 and IE7 (with limits in IE8).

Useful Tools

  1. Yahoo's YSlow ", a Firefox add-on that "analyzes web pages and suggests ways to improve their performance based on a set of rules for high performance web pages".
  2. Firebug's Net tab can show you a timeline of file loads.

There was a brief discussion of other performance enhancers, like Varnish and Memcache, Project Mercury and Pressflow.  The investigation of these is left as an exercise for the reader.  A new book from Packt Publishing just came out entitled "Drupal 6 Performance Tips" that might be useful as well.

 

Debugging Drupal Remotely with NetBeans and LAMP

Prerequisites: PHP, NetBeans, Linux Administration

We at Tarakan Design came to the web development world after spending many years in traditional software development. One of the tools we missed was a readily available interactive debugger for our PHP scripts, particularly for remote servers. Sure, there were PHP debuggers out there, but setup was marvelously complicated and results were, well, let's just say that our mileage did vary. Fortunately, setup is now simple if you use NetBeans and a LAMP-based development server.

For these instructions, I used NetBeans v6.8 and Ubuntu Server v9.10.

Configuring the Server

The first thing you have to do is install the Xdebug extension for PHP. The good news is that installation these days is a breeze. Just open an SSH session and install it with the aptitude package manager:

$sudo apt-get install php5-xdebug

This should create the file /etc/php5/cli/conf.d/xdebug.ini. Let's have a look inside. It should already have the Zend extension defined:

zend_extension=/some/path/to/xdebug.so

We just need to add a few lines to enable it to work with NetBeans remotely:

 

;Enable remote debugging  
xdebug.remote_enable=1 
;Select the debugger protocol (php3 or dbgp) 
xdebug.remote_handler=dbgp 
;Select when a debug connection is initiated. 
;  req tells Xdebug to try to connect to the client as soon as the script starts. 
;  jit tells Xdebug to only try to connect on errors. 
xdebug.remote_mode=req 
;Set the IP address of your local machine, not the server 
xdebug.remote_host=192.168.1.9 
;Set the port. 
xdebug.remote_port=9000 

 

Save the file and restart Apache

$sudo /etc/init.d/apache2 restart

That's it for server configuration. Now on to the client...

Configuring the Client

All you really have to do is make sure the client and server files are in sync and tell NetBeans where they are. An easy way to do this is to start with the site files on the server and create a new NetBeans project by importing them:

  1. Start NetBeans and create a new PHP project (File->New Project). Select PHP Application from Remote Server and click Next.
  2. Give the project a name and local location and click Next.
  3. Setup the Remote configuration as appropriate for your server and click Next.
  4. NetBeans will construct a list of files it will download. Click Finish to download the files locally.

When it's done downloading, NetBeans will bring up index.php from the Drupal root. Right-click anywhere in the file and select Debug File. The debugger will automatically stop on the first line. From here, you can set any breakpoints you need by opening the source file, right-clicking on the desired line and selecting Toggle Line Breakpoint (there are a few other ways of setting breakpoints as well). Via toolbar, hotkeys or the Debug menu, you also have familiar interactive debugger functions like run, step over, step into, step out, and run to cursor. At the bottom, you have panes for watches, variables and the call stack.

And with that, we've reclaimed interactive debugging for our Drupal development toolkit. The gods of productivity will be pleased.

Syndicate content

Our Philosophy

 

  • Customer centered, Agile development
  • Clear and open communication
  • Solid software engineering principles

 

Drupal

Drupal

 

We use the Drupal Content Management Framework for secure and reliable websites.
Learn More