PHP

Moshe and merlinofchaos for pointed me in the right direction for the function to modify if you want to remove divs that are output in a list view block via the Views module. To strip out those divs, do something like below in your PHP Template's template.php file:

function phptemplate_views_view_list($view, $nodes, $type) {
  $fields = _views_get_fields();
  foreach ($nodes as $node) {
    $item = '';
    foreach ($view->field as $field) {
      if ($field['label']) {
        $item .= '<div class="view-label view-label-$field[queryname]">'. $field['label'] ."</div>";
      }
      $item .= views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view) . "<br />";
    }
    $items[] = "$item"; // l($node->title, "node/$node->nid");
  }
  if ($items) {
    return theme('item_list', $items);
  }
}

Thanks to everyone for the suggestions.

It's the little details that make the difference in a clunky design and one that communicates with brevity and elegance. One thing that I've always hated in my Drupal blog is the wordiness of my author/date/comment line. You know what I'm talking about. In node.tpl.php it's the stuff you get when you print out $links.

Well, I resolved to make things cleaner in the next blog theme I work on, so that I can get displays more like this:

By jibbajabba on 21 Feb | 1 comment

Rather than this:

February 21, 2007 - 10:06am
jibbajabba's blog | 1 comment

I know it seems like such a minor thing, but it's little things like wanting to change that, but being too lazy to go figure out how to do it that keep me using the default display in my themes. Well, no more. On the bike blog (Love & Sprockets) I'm going to do it this way:

By <?php print $name; ?> on <?php print format_date($node->created, 'custom', 'd M'); ?> |
<?php
 
print $comment_count . ' comment';
  if (
$comment_count != 1) { print 's'; }
?>

Or using the format_plural function, which chx pointed out:

By <?php print $name; ?> on <?php print format_date($node->created, 'custom', 'd M'); ?> |
<?php print format_plural($comment_count, '1 comment', '@count comments'); ?>

Ahhh. I feel better now.

I resurrected the GraphViz Sitemap Generator I created 5 years ago. The generator takes a file with tab separated values as input -- 1 line for each node of a sitemap or flow chart -- and outputs hierarchical or radial graphs as GIF and SVG.

The generator was on a long hiatus because I didn't want to keep maintaining it, but I dusted it off to do a quick graph. You can expect it to stay up indefinitely, but I don't predict it will get that much use since we have such good desktop tools for doing this kind of thing. It is nice for running large text files through it, however, which is why I use it occasionally.

Someone asked me how I display different header images on urlgreyhot depending on what section (corresponding to the global nav tabs) you are viewing. My solution might not be exactly simple or the best way to go, but it works. Here are the steps:

1) I use the path_auto module to create URLs depending on either node type or vocabulary. So in my pathaoto settings I have weblog entry urls created as "weblog/[title]" and everywhere else the URL is either created manually or built based on the category (taxonomy term) so the services section urls are "services/[page title]".

2) In the PHP-Template theme, I do a regular expression check to see what the path is and assign a variable depending on what section we're in, e.g.

$dapath = $_SERVER["REQUEST_URI"];
if (eregi("/personal/services*.*",$dapath)) {
  $sect = "services";
}

3) I put that variable in the body tag:

<body id="<?php echo $sect; ?>">

4) I place an empty div in the page, which will be the placeholder for header image:

<div id="section-header"></div>

5) I put a rule in my style sheet to display the appropriate image depending on what section is being displayed:

#services #section-header {
  height: 131px;
  background: #fff url(bg-sect-about-me.jpg) top right no-repeat;
}

This is also how I display a selected tab in the global navigation. The idea there would be to make each link in the nav have an ID, so you can then apply a CSS rule for #services #services-menuitem, for instance. It's a serviceable method. Do you do something similar in a perhaps more elegant way? How do you do it?

Here's a tip that only an information geek would care about. If you've ever looked at my taxonomies, you'll know that I describe nodes by facet, e.g. file format, person, subject. Years ago, in another version of Drupal, I used to show terms applied to each node by facet, but with the upgrades and changes to the taxonomy module, I gave up trying to keep that up to date. Luckily, I found in the PHP-Template documentation, that someone posted a snippet for sorting/displaying terms by vocabulary. So I'm using this snippet to display my terms by facet again.

Here's a screenshot of terms in action:

Like I said, that's the kind display of metadata that only a info geek would want. But I think it also demonstrates to people new to Drupal the kind of description/categorization of content that might be useful in different environments, e.g. a corporate intranet.

So to do this, use the following code in your node.tpl.php (snarfed from drupal.org):

<?php if ($terms): ?>
<?php /* sort taxonomy links by vocabulary 27 */
$terms27 = taxonomy_node_get_terms_by_vocabulary($node->nid, 27);
if (
$terms27) {
  print
'<div class="terms">Forums: ';
     foreach (
$terms27 as $key => $term27) {
    
$lterm27 = l($term27->name, 'taxonomy/term/'.$term27->tid);
  print
$lterm27.' - ';
     }
  print
'</div>';
}
?>

<?php endif; ?>

You would repeat that code block sandwhiched between "if($terms) ... endif" for each set of facets you want to display.

PunBB is a fast and lightweight PHP-powered discussion board. It is released under the GNU General Public License. Its primary goals are to be faster, smaller and less graphically intensive as compared to other discussion boards. PunBB has fewer features than many other discussion boards, but is generally faster and outputs smaller, semantically correct XHTML-compliant pages.

I've been struggling to get a working version of Dadabik installed that allows you to select multiple values from a foreign table. I had some success with someone's patch that does this, but so far I can only get it to insert the labels for the field I want and not the id. I want the interface to show state names in the editing form, in this instance, but to insert the ID for the state name. For some reason, the Dadabik folks took the ability to select multiple values from a foreign table out of Dadabik after version 2. No idea why.

Then I found in the phpMyAdmin documentation some information about using $cfg['Servers'][$i]['relation'] and $cfg['Servers'][$i]['pmadb'] to set up foreign table relationships. This looked promising, but only allows for single value selection and only shows the ID of the foreign key for selection and not the values in another field of the foreign table. Not very useful from the data entry user's point of view.

So I'm casting about wildly for a tool that allows me to do this so I don't have to spend time trying to do it in Adodb or ezsql. Sigh. Any suggestions?

----

Incidentally, if you're wanting single value selection from a foreign table, Dadabik does it well. If you want to do it phpMyAdmin, you'll need this process and table structure for creating the relations table, which I snarfed from php-myadmin-users archive.

* set up a PMA database as described in docs

* within this database create a table following this scheme:
CREATE TABLE `PMA_relation` (
`master_db` varchar(64) NOT NULL default "",
`master_table` varchar(64) NOT NULL default "",
`master_field` varchar(64) NOT NULL default "",
`foreign_db` varchar(64) NOT NULL default "",
`foreign_table` varchar(64) NOT NULL default "",
`foreign_field` varchar(64) NOT NULL default "",
PRIMARY KEY (`master_db`, `master_table`, `master_field`),
KEY foreign_field (foreign_db, foreign_table)
) TYPE=MyISAM COMMENT="Relation table";

* put the relation table name in $cfg["Servers"][$i]["relation"]

* now as normal user open phpMyAdmin and for each table where you want
to use this feature, click "Structure/Relation view/" and choose foreign
fields.

The PEAR::HTML_QuickForm package provides methods for creating, validating, processing HTML forms.

Open source bookmarks manager using PHP/MySQL.

PHP/MySQL classified advertising application.