Blog

Safari Flash Cache

Dan's picture

If you are having trouble getting rid of a stale .swf with Safari
open ~/Library/Caches/Metadata/Safari/History/
Delete files at will then clear the Safari cache and reload.

UPDATE:
I found iPurge Safari Cache

Which does the trick!

Content Type Selector saves a few previous seconds

Ben Buckman's picture

CCK's standard "Display Fields" settings are good for configuring per-content type field visibility and can save a lot of custom coding time. If a field is shared over a dozen content types, however, a change to one has to be made to the others, and that's a lot of clicks.

The Content Type Selector module adds a little dropdown to the right of the tabs on the CCK settings pages. So you change the field settings on one content type, pick the next type in the dropdown, change it there, etc. It's still a lot of clicking but it's a few seconds trimmed with each page and feels more seamless.

Popup for External Links (jquery)

Travis Black's picture

I have been asked by multiple clients lately to provide a feature that will cause ANY link to an external site, alert the user that they are leaving the site before they go. At first I was unsure how to do this, but jQuery made it beautiful, as it does most things.

Today I Learned: Translate custom (core) strings

Ben Buckman's picture
Tags:

On a site we're starting to build, Drupal's core "Sticky at top of lists" functionality isn't necessary (using Nodequeue for lists), but nodes need to be included or excluded from search results on a per-node basis. Rather than create a custom CCK field, and since we're building search (as usual) through Views, I decided the simplest answer was to rename "Sticky" to "Appear in Search Results," and filter accordingly in the view.

So how to do this? hook_locale() only works on non-English languages (see t()) and seems to define groups rather than strings.

The simplest solution, it seems, is to use settings.php (or in this case, a common.settings.php used by all the others). Like so:

  1. $conf['locale_custom_strings_en'] = array(
  2. 'Sticky at top of lists' => 'Appear in search results',
  3. );

Voila! It works even with the Locale module disabled. (It's not really needed since it's an English-only site.) And since the string is always run (by core and Views) through t(), it applies universally. It's still `sticky` to the database but that doesn't matter.

Today I learned: about max() array magic

Ethan's picture

Today I learned:

  1. That there's always more tricks in the PHP bag
  2. That the max() command will return the element with the highest-value key when returned an associative array. So, given $a = array(1 => "red", 5 => "green", 10 => "blue");, max($a) will return "blue".

New to me: Popups module

Ben Buckman's picture

I've started using and loving the Popups API module. It allows other modules to create lightbox-type ajax popups of other pages and forms. Out of the box, it includes the option to convert several admin UI pieces into popups, like the Configure Block links, Taxonomy Add/List/Edit links, etc. Saving a few seconds here and there adds up to a lot of time!

(Note: Make sure to set the Content Selector in your theme settings (/admin/build/themes/settings/themename). The default is strange, but in most themes div#content should do it.)

Symfony and svn:externals... super-slick the easy way

Ethan's picture

(If you already know about Symfony and just want to use svn:externals to install it, you might want to skip here)

We've begun using the Symfony MVC framework for some small projects and really getting into it. If you're not familiar with MVC frameworks, then...well, you probably are more familiar than you know: the MVC patternis the design pattern at the heart of well-known development frameworks like Rails and Django. PHP has its own varieties of MVC frameworks, and Symfony ranks along with other popular options such as CakePHP and Code Igniter.

Like most MVC frameworks, a large part of what makes Symfony such a powerful tool is it's meticulously organized codebase. Placement of each piece of the stack is exquisitely thought-out, providing the foundation for an extensive plugin-architecture capable of interfacing with and incorporating numerous third-party libraries and tools. Like any intricate protocol, however, the organization of Symfony's code can be somewhat daunting and labyrinthine, contributing to its fairly steep learning curve.

Luckily there are some great tutorials and references out there, including the freely available version of the commercially published Symfony Book, the Getting Started Guide and a bunch more.

PDF Forms

Dan's picture
Tags:

One of our clients has a simple enough request. They wanted a PDF form to be populated in with a set of values gathered from a web form. We decided to settle on xfdf as a method to do this.

I wasn't familiar with xfdf, but was pleased to discover it is an easy format.

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">
  3. <fields>
  4. <field name="firstname">
  5. <value>Dan</value>
  6. </field>
  7. <field name="lastname">
  8. <value>Cocos</value>
  9. </field>
  10. <field name="email">
  11. <value>dan@echoditto.com</value>
  12. </field>
  13. </fields>
  14. <f href="example.pdf"/>
  15. </xfdf>

Now that the xfdf problem was solved we had to move on next to adding the fields to the PDF. We were unable to find suitable PHP libraries to handle it. Luckily there is a free and open source Java* library iText that does all of this and more.
Miles an EchoDitto intern took the first crack at it and had a working example in no time. A little bit of code clean up and voila a short while later a working tool to merge form data into a PDF.

*There is also a C# port for those so inclined.

Using SVN Merge for Dev-Prod Web Deployments

Ben Buckman's picture

We use Subversion (SVN) to manage our code, and typically branch the code from 'dev' to 'prod' at launch time, with each project's tech lead determining the best way to manage the two repositories in parallel for subsequent development. SVN, like any decent versioning system, has branching and merging functionality, but until recently I had little success (and some disaster) trying to use it. So I used the cruder but tried-and-true method of locally rsync'ing dev to prod (with -rC for recursive and ignoring SVN metadata) and committing the changes to each separately. That mostly works fine, except it can be a very tedious process (using FileMerge to check every file and figure out which branch's version is correct); it makes SVN's logs very difficult to understand (with no clear history to a file and duplicate commits of everything); it's easy to make a mistake and mess up a branch; and it seemed unnecessary given SVN's built-in functionality. In some cases, the dev and prod branches got so out of whack that the developers had given up on merging them, and all development was done on local copies of the production branch, an inefficient (and dangerous) method that made branches pointless.

So on my latest post-launch project, I decided to figure out SVN merging. The first deployment process took 2+ hours with a splitting headache at the end; then 1 more lucid hour; now it's 5 minutes, so I do this even for extremely urgent fixes. svn help merge describes multiple ways to use the command; this is how I've gotten it to work.

Environments module: simplifying developers' management of 2-dimensional site environments

Ben Buckman's picture

This week, I released a Drupal 6 module called Environments (shortname Envts), my first released module and EchoDitto's first for Drupal 6. Its purpose is to help developers manage "two-dimensional" Drupal site environments. Drupal is fairly good at running multi-site builds, with sites folders and different settings.php files. Modules like Domain Access are good at managing those sites one-dimensionally - a single list of hosts with primary (mysite.com), secondary (special.mysite.com), etc, and deep integration with Views and other modules.

But this single list of sites is built for one environment: one set of domains, such as for a live site. For example:

  • dartcenter.org [primary]
  • dartsociety.org [secondary]

Domain Access is good at listing these domains and filtering nodes by them. But in our work, there's never only one environment. There's a development environment -

  • dartcenter.dev.echoditto.com [primary]
  • dartsociety.dev.echoditto.com [secondary]

- and each developer usually has a local server environment -

  • dartcenter.ben.local [primary]
  • dartsociety.ben.local [secondary]

- and sometimes there's a staging server between dev and live -

  • staging.dartcenter.org [primary]
  • staging.dartsociety.org [secondary]

- and so forth.