Popular content
Pre-fill comment subject line
I often find it handy to make a small module for most of my Drupal project the purpose of which is to perform little tweaks on default Drupal core or other module behavior. Usually this small utility module lives in /sites/all/modules/custom/tweaks/tweaks.module or something to that effect.
Having such a module around is a quick way to tap into the power of Drupal hooks. For example, a client requested that the subject lines of any comments be pre-filled with the node name, prefixed with "Re:". This was easily accomplished with a quick hook_form_alter, like so:
Number to Month 1
<?php
/*
* The script will print "Mar"
* See php.net/date for more formatting options
*/
$m = 3
print date('M', mktime(0,0,0,$m,1,date("Y")));
?>
The Internet? Bah!
A friend passed this article my way. It was written in 1995 which was, of course, the same year Windows 95 happened.
A Complete Soul 1
I just read a very good article about an old man who repaired typewriters during World War II and beyond. Very recommended.
http://www.theatlantic.com/issues/97nov/type.htm
For some reason, I really like old things that aren't "useful" anymore. I have a slide rule and a typewriter on my desk next to my multi-core, Internet connected computers. I'm not so much a pack-rat, I don't think (maybe consult with my wife on that question), I just like great things, no matter when in history they were considered great.
Drupal Views count results 1
Here's a cool trick, drop this code in your views display header to show how many rows were returned by the query (be sure to use the PHP code input format):
There are currently <?php
$view = views_get_current_view();
echo $view->total_rows; ?> records displayed.
I imagine that the views_get_current_view() function can come in handy for other purposes.
Turkey in a Quilt
Pop-out crescent rolls
Turkey
Bell Pepper
Tomato
Mozzarella cheese
Pop-out crescent rolls were on sale and we had some turkey from somewhere, so we sliced the turkey into little logs and rolled it into the rolls with a slice of tomato and green bell pepper, then baked them as you would bake the rolls. It came out pretty good. We didn't have any mozzarella when we did it, but I imagine it'd be really good in there.
Commonly overridden node form elements
In order to save some time putting print_r in the form override, here are the keys of form elements I often override.
"Menu settings" fieldset = $form['menu']
"Revision information" fieldset = $form['revision_information']
"URL Path Settings" fieldset = $form['path']
"Comment settings" fieldset = $form['comment_settings']
"Authoring information" fieldset = $form['author']
"Publishing options" fieldset = $form['options']
if the publishing options is simply unset, the node will default to unpublished. If you want nodes to always be published, do this:
Overriding forms Drupal 6
I find myself needing to override a form fairly often, and I'm always having to go after the process, so I'm making a note of it here. I often need to override node edit forms in order to get rid of unneeded form elements.
My reference has been this article at lullabot.
The first thing you need is the Form ID. To find this, load the form in question in a browser, then view source. Search the source for "form_id". You should find a hidden element with "form_id" as its name, like so:
Apricot jam, cream cheese, and turkey?
This isn't a combination you would think would be good at all, but it's really good. Trust me.
Works very well as a wrap, but also good between two slices of white bread.
Just put some apricot jam, cream cheese, sliced turkey, and a leaf or two of lettuce, if you have any, in a tortilla and roll it up. Kids, if their young enough not to think it's weird, really like it.
Got this one from my sister.
