drupal

Use Syslog instead of Watchdog

Alan Ivey's picture

It seems to be standard for Drupal, at least in version 6, that Watchdog is enabled and used to write errors/warnings/notices to the watchdog table in the database. Depending on the verbosity of your PHP output, amount of 404s, or other information that would be going into this log, it could mean a lot of writes on your database. While you should trace errors/warnings and solve them, sometimes you may want this increased information for debugging. If your site receives a lot of traffic, this could mean decreased database performance. A solution to this is to instead utilize the core Syslog module instead of Watchdog. Here's how I got it set up in Drupal 6 on CentOS 5 servers.

Views Search by Link Module's URL Title: More Views Hacking

Jeremy John's picture

So recently I wanted to filter by URL title, having used it extensively as a text field with an optional link in a site.

The code below is supposed to apply to an exposed Link module field filter in Views. Instead of searching to see if the search string matches the URL, this will match the URL title that was provided.

In the code below, you would replace node_data_{field_publication_author.field_publication_author} with the name of your field, in all places that "field_publication_author" occurs in the below.

Removing Behaviors Using a GMap Macro

Paul Venuti's picture

I'm building some maps for a client using the GMap module and came across the following simple problem: using a GMap macro, how do you remove a default attribute?

The GMap module lets you set a number of default attributes for your maps: width, height, center position, initial zoom, and so on. If you want to change any of the default settings for a given map, you need to specify your overrides in a GMap macro, which looks something like this:

[gmap zoom=3| width=500px |height=350px]

It's all simple enough until you get to the behaviors.

Setting JS Callbacks with Drupal, JSON and Some jQuery Sauce (for jCarousel controls)

Ethan's picture

Sometimes a few characters of code can make all the difference in the world. All coders know the scenario: the code looks fine, all the right values are in the right place, the code validates or compiles (or at least looks like it should), but when we run it we get...nada. Maybe the source of the problem is a comma following an array declaration (fine in PHP, but can be a killer in JS), an extra "$" in a variable name, or - as in the case of trying to define a callback for jQuery libraries like jCarousel using JSON - an extra pair of quotes around the callback function value.

Unfortunately, the difference of a few quotes is not always so easily overcome. In the case of extraneously quoted JSON function values, for instance, the issue originates from within the drupal_add_js function and PHP's own json_encode. Such situations can lead to desperate measures: grabbing the drupal_get_js output and munging it with regular expressions or other hackish means to make it do what we need. While use of such techniques is something of a religious dispute among Drupalists, I'm happy to announce that there's also another way to tackle JSON callbacks in Drupal, with nothing more out-of-line than drupal_add_js and a bit of simple jQuery magic.

Keep Drush Up to Date

Alan Ivey's picture

We're big fans of Drush. It's installed on all of our servers and it's a great way to perform maintenance tasks, download core and modules, and much much more. I'm not a big fan of installing from zip files though, so let's use git to easily keep our Drush install up to date.

Set Sitewide Default Context in Drupal

In Context 3 they removed the sitewide default context, that is, the context that can be set to be enabled when no other context is active. The sitewide context, which is enabled at all times, is still available.

But, in its place, Dev Seed has added a very powerful feature, sneakily powerful, in fact.

You can set a context to be active using another context. Seeming kind of meh? Well, read on. You will soon see, young apprentice, just as I did just earlier today.

First, name all the contexts you DON'T want this context to coincide with in a regularized way, like

DrupalCon Chicago: A Roadmap for Drupal 8

Paul Venuti's picture

While Dries' keynote touched on a number of topics -- from the scalability of Drupal to individual shout-outs to the top 30 core contributors -- the bulk of the talk focused on the roadmap for Drupal 8. Here's a quick rundown of what we can look forward to in the next release of Drupal:

  • Drupal to any device, particularly mobile ones. If you look at the prevalence of net-connected computing devices in 2011, desktops are a minor, stagnant sector, whereas mobile devices -- anything from a smartphone, to a laptop, to a TV -- are more numerous, and their numbers are increasing.

Git Access on Drupal: How to Get and Use Git to Start Committing Modules and Patches

Want to contribute back to the Drupal community? Don't be afraid, Git is not as hard as you might think. There are plenty of resources available to those who search. Drupal recently switched over to Git from CVS. Much of the documentation on Drupal.org is out of date, so if you see documentation related to CVS, remember that Drupal now uses Git.

This post will serve as a way of helping you to get involved in the Drupal community and contributing modules back.

Get Git Access

Google Analytics and Drupal's Scheduler: How to be first in line

Ethan's picture

This post was not written at 7 AM. Using Drupal's Scheduler module it was automatically posted at a carefully calibrated time in order to get the most number of visits.

Now don't be fooled by that whole "carefully calibrated" bit, though. While post time does have some impact on social media shares and RSS reader share, it's not the most important factor. Not by a long shot. Real, sustainable audience growth comes from regular, high-quality content and responsive relationships to your online readers.

Modify Views SQL Query in Drupal, Restrict View to Search Term

Jeremy John's picture

So I wanted to be able to pass a default value to the the Views search filter, to filter by a view by a search term, to display that view in a block.

EDIT: There is an easier way to do this, which renders this whole tutorial useful only for other SQL hijacking. Under Filter, select Node: Body. See screenshot.

I had two options, create a view, create an RSS feed, run it through Yahoo Pipes, and cycle it back through, or modify the views query.

Nodereference Fails to Print Referenced Node

I had a case where CCK nodereference wasn't populating the view field in the array, so I had to check to see if it was empty and then manually populate it.

I leave this code as a gift to posterity.

<?php foreach ((array)$node->field_speakers_noderef as $item) { ?>
        <?php if ( $speaker_view = $item['view'] ) : ?>
                <div class="field-item"><?php print $speaker_view ?></div>
        <?php else: ?>
                <div class="field-item"><?php print node_view(node_load($item['nid']), TRUE); ?></div>
        <?php endif; ?>
<?php } ?>

Drupal 6.x + jQuery 1.4.2 = New Possibilities

Déja Augustine's picture

jQuery is the bread and butter of rapidly developing a highly-interactive websites, and Drupal has long made use of it, and indeed includes it as part of its core install.

How to Configure Eclipse PDT with Zend Server Debugger on MAMP for Drupal

Anything involving Eclipse is always epic. First, you have to get your head around what distribution of it to use, as confusing as one's first introduction to Linux distributions (there are different kinds of Linux?).

Next, you have to grok the fact that the Zend Debugger must be installed on your server. In this case, MAMP.

Then, you have to make Eclipse listen to the debugging information being outputted, on the debug port.

Finally, you have to figure out how to use a debugger effectively (not in scope, but careful, debugging will blow your mind).

Upgrading Open Atrium past the beta4 boundary

Déja Augustine's picture

Open Atrium (http://www.openatrium.com) is best described as an "Intranet in a box" that sits atop Drupal 6. With the release of Open Atrium 1.0-beta4, Development Seed made a few crucial changes to the way OA is configured and structured. Now at beta7, there are still some older OA sites out there that are still running versions prior to beta4. Those sites require a little extra work to upgrade since they need to be upgraded to beta4 first, and then can be upgraded to beta7 and beyond.

Using Tokens in Comment-Triggered Email Notifications

Ethan's picture

The stock "Send Email" action type that ships with Drupal 6 does't offer a whole lot of options for including content from comments in your triggered emails.

In fact, it doesn't offer any.

There has been a good deal of discussion on this: a patch has been proposed and a stop-gap helper module has been posted to drupal.org.

Before you go that route, though, check out this post on using the Token Actions module to provide access to the full array of available tokens in your email. Thanks to Erik Weik at New Rivers Digital for the great post.

We're using Trigger-based email notifications to fight spam and help our clients be engaged with their commenters.

How do you use and implement comment notifications?