Drupal Planet

Feeds set-up for Aps

Here is some documentation for setting up feeds in Drupal 7 so that An iphone or Android ap can access the data.

The data brought together using Views and then output using the JSON from the "views_datasource" module.

First and Last Class on a list

This function appears in the Codit Module

Here is a function that allows you to quickly get back a class as 'first', 'middle', 'last' and in a case of a single item list 'first last'

Adding Field data to Alias Pattern

In order to use a field's data within a replacement pattern inside of path auto, you need to enable "Entity Tokens" from the "Other" module section. Flush the cache after enabling the module to get the new tokens to show up.

Site archiving (harvesting)

In cases where we are replacing an existing site that is not ours, we often want to have a copy of that site but for some reason are not in control of the existing server. We need a way to harvest a copy of that site including images, stylesheets js files...

HTTrack Website copier works quite well
http://www.httrack.com/

Codit: Template Tracers for Drupal

One of the confusions with Drupal is knowing where content is coming from, what tpl controls it and where the tpl resides. Place the following template tracer code at the start and end of the output on a tpl and this will never cause confusion again.

Revealing the actual location of the template file is made secure by only revealing the template location if the user has permission to see template tracer output.

Setting up a CSV for import with feeds

Steps for sanitizing a spreadheet for import into feeds
a) Move the field mapped to the title to the first column of the spreadsheet.
b) Remove any duplicate entries for if duplicates will cause a problem
c) Save sheet as msdos csv
d) change file extention from .csv to .txt
e) replace the following with items in the brackets [] pay careful attention to spaces in them
[?] -> [']
[ ' ] -> [ ]
[ÿ] -> [space]

Feeds : importing geolocation

For some reason the geolocation field does not show up as a field that can be imported. It requires an additional field importer to make the geo latitude and longitude fields become available.

The additional importer comes from #5 in this post
http://drupal.org/node/1294604

Simply place the file in the feeds/mappers/ directory.

An important lesson learned here: If the geo fields are mapped on an importer, the import will fail if the geo fields have no data or are empty.

Feeds: Addresses - importing an address

NOTE: Feeds address is tempermental. If you are bringing in US data you must import a country code of "US" and a state codes must be two letter all caps like "FL" or "NY".

Caching intensive processes in Drupal

Yes all of Drupal's pages are cached by ordinary page caching. However, some processes are so intensive that we want to cache them beyond Drupal's default. Good candidates for such caching are lists of cities within regions.
UPDATE: A more refined method using Drupal static and caching should be used
Here are the basics for caching the return of a heavy function.

Codit Blocks

  • Blocks can be added quickly  through code (similar to custompage blocks, but without any admin or database changes) by adding a block directory and template, then flushing cache.
  • Any block can have a callback function that automatically takes what it returns and puts it in the $variables array for the tpl to access.  These callback functions should only return data, not markup.  Save the processing of turning data into markup for the tpl.   Callback function also easily handle caching and permissions access.
  • Can be used to override any block title, including the ability to disable all block titles except any that have been overridden.
  • Block placement can be handled by the Context module, Panels, or the block admin.

Pages

Subscribe to RSS - Drupal Planet