Wednesday, June 27, 2007

Drupal $head_title versus $title. Split 'em.

So, you built a nice new PHPTemplate theme. You followed the samples and in your <title> tag, you place the $head_title variable and in your section header you display the $title variable. They are different titles, or are they?

Short answer is yes, they are. However if the module generating page content happens to use the drupal_set_title() function, then the value of both title variables will be the same. This is not always what you want.

Some quick reading and modification of our template.php file resolved this for us.


function _phptemplate_variables($hook, $vars = array()) {
switch ($hook) {
case 'page':
switch ($vars['node']->type) {
case 'project':
$vars['head_title'] = $vars['node']->title;
break;
case 'quarterlyreport':
$vars['head_title'] = $vars['node']->title;
break;
}
break;
}
return $vars;
}


The key here is that the node attributes are accessible in the _phptemplate_variables function of the PHPTemplate. Therefore we can create conditional logic based upon node->type, node->status, etc...

Finally, any of the template engine variables are accessible and can be set or unset prior to the generation of the output. Remember the $head_title variable? See how we modify it based upon node properties.

Drupal 4.7 Allow Certain Role Users to View Unpublished nodes for Custom Module

If you're like me you have come across a need for non-admin role users, like a content editor, to be able to view unpublished nodes of which they are not the author. By default, Drupal does not allow non-admin users who are not the node author to view unpublished nodes.

Of course, Drupal being a great platform to extend, you can resolve this in your custom module.

In the
hook_access
function of your custom module, just try code similar to this:


if ($op == 'view' &&
(user_access('edit periodic updates') ||
user_access('edit own periodic updates')) &&
$node->status != 1) {
return TRUE;
}


What you are telling Drupal is if the node operation is 'view' and the user has one of the specified two role permissions and the node status is not published, then allow the view access.

Easy enough.

Friday, June 8, 2007

Ubuntu Desktop 7.04 Installation and Wireless Issues

Well, I finally got around to it. I got out the Ubuntu 7.04 Desktop CD and decided to dual boot my laptop. After witnessing first hand the demise of a fellow staffer's machine using the Ubuntu disk partitioner, I opted for another manner.



First I used Partition Magic 8 in Windows XP to make the XP partition smaller, freeing up room for the Ubuntu installation. For testing purposes I gave Ubuntu 8GB of disk space. After a reboot and letting Partition Magic do its thing it was time to install.



I booted from the CD and chose a standard install. About 35 minutes later, I had an Ubuntu desktop staring back at me. Now what, I thought. I was used to the Linux distro's of yesteryear with command line syntax and all. (Showing my age now!) One of the first things I noticed is that Ubuntu had already mounted and made available my NTFS partition for Windows XP with read-only access. COOL! I had immediate access to my mp3s that I had on Windows XP from within Ubuntu. Sure enough, I double clicked one and boom, it started playing.



Now how about FireFox. Yup, right there. Yes, the network connection is working and really good download speeds. Wow, about 3 times faster than XP. Hmmmm, guess I better look into tweaking XPs TCP settings. Uh oh, trouble. The wireless connection is not working.



Well that is the one and only thing thus far I have had trouble with. Thanks to an article I found on installing the ndis-wrapper, I was only a few commands away from having my Dell Wireless Mobile 1390 working painlessly with WPA-2/AES encryption over 802.11G. I had to download the correct drivers from Dell, extract them and then use ndis-wrapper to install the bcmwl5.inf. Then all that was left was to restart networking.



So far, I am really impressed. I am thinking about trying to install Ubuntu on a spare machine then VMWare and then load Windows XP on VMWare. Now that would be a change. Any thoughts?





Powered by ScribeFire.

Creative Use of PNG Transparency in Web Design by Jeff Croft

Jeff has a superb article on the Digitial Web Magazine site regarding PNG Transparency. I really like this article for the pure simplicity of his explanation of what I deem as a pretty elegant solution. Now, maybe I'm way slow here (as usual) but Jeff really got me thinking about the possibilities of the alpha-channel transparency of PNGs.



Just a side not for those of you in the Bible Translation World, I don't mean Papua New Guinea when saying PNG above. ;o)









Powered by ScribeFire.