Tuesday, November 25, 2008

having trouble with no "active" class being generated for menu's or primary/secondary links (
  • ) in Drupal 6.x? It has been documented that 6.x has issues with generating an active class ... at 6.5 the active
  • is classed as "active-trail", so if you are bringing in a theme that worked at 5.x this might be the issue.

    For me it was a naming issue within my primary links configuration (the same would be true for a menu). You must use a Drupal recognizable path such as "" for your homepage or "data" for a page at "http://www.yoursite.com/data". To avoid this, make sure to select this menu when creating new content.
  • Monday, November 10, 2008

    with the php domdocument class was getting the following error:

    Warning: main() [function.main]: unterminated entity reference 64-bit

    this error was occurring when trying to set the name of an anchor element ... the same error popped up when setting both within the constructor and through the nodeValue method. I haven't tested the solution via the constructor, but by wrapping the value with the built-in htmlspecialchars(), I solved this error

    $anchornode = $doc->createElement('a');
    $anchornode->nodeValue = htmlspecialchars("$somevalue");

    create dom html with php, getelementbyid doesn't work

    I leverage the domdocument php class to create elegant, dynamic html documents via the dom tree. However, I was finding that the "getelementbyid" method was not returning elements as expected. The reason for this is that I had not defined a DTD, which is necessary in this case because we only specify that we are saving as HTML at the end of the process, so the domdocument object is only understood as generic XML, which has no predefined "id." To create a DTD use this code (here using 4.01 transitional html):

    $doc = new DOMDocument();
    $doc->loadHTML('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">;');
    there are so many options with pear's db library for php, I sometimes forget the optimal code for getting a sql result as an array that I can easily use within php. The code below fully demonstrates connecting to and getting an associative array with an 'order by' field as the array key. This code is for a postgres rdms, but could easily be modified for mysql, sqlserver, etc. Parameters are in caps surrounded by '%' in the form %PARAMETER%.

    require_once 'DB.php';

    $dsn = "pgsql://%LOGIN%:%PASSWORD%@%HOST%/%DBNAME%";
    $dbh =& DB::connect ($dsn);
    if (PEAR::isError($dbh)) {

    $res =& $dbh->getAssoc('%SQL STATEMENT, USE 'ORDER BY' TO DEFINE ARRAY KEY%');

    if (PEAR::isError($res)) {