create blog name if one doesn't exist
dafeder - March 26, 2008 - 13:40
| Project: | Blog Information |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
This isn't exactly a feature request - I wanted to have the module create a block even if the user hadn't given his blog a title, for design consistency. Thought I'd share with others who might be interested, and suggest that something like this be incorporated into future versions...
It's a simple modification to bloginfo_block():
<?php
function bloginfo_block($op = 'list', $delta = 0) {
if ($op == 'list') {
$blocks[0]['info'] = t('Blog information');
return $blocks;
}
else if ($op == 'view') {
if (arg(0) == 'node' && is_numeric(arg(1))) $node = node_load(arg(1));
if (((arg(0) == 'blog' && is_numeric(arg(1))) || $node->type == 'blog')) {
if (arg(0) == 'blog') $authorid = arg(1);
else if ($node->type == 'blog') $authorid = $node->uid;
$count = db_result(db_query("SELECT COUNT(*) FROM {bloginfo} WHERE uid = %d", $authorid));
if ($count == 1) {
$results = db_query("SELECT title, description, format FROM {bloginfo} WHERE uid = %d", $authorid);
$bloginfo = db_fetch_object($results);
$block['subject'] = check_plain($bloginfo->title);
$block['content'] = theme('bloginfo_block', $bloginfo->description, $bloginfo->format, $authorid);
return $block;
}
else {
$block['subject'] = t("@blogname's blog", array('@blogname' => $node->name));
$block['content'] = ' ';
return $block;
}
}
}
}
?>Obviously you can put something into the content element if you want, I just wanted that blank for my users.

#1
No new features in D5 version so moving it forward for later consideration. Fell free to rerole the code snippet against 6.x-1.x-dev or even better give a patch.