Changents
Where in the theme are the tabs printed / giving tabs to admins only
On giving View, Edit, Revision, etc. tabs to administrators only.
In Drupal, tabs are not printed by the node, but by the page. On the one hand, since views and administrative pages and anything else you can think of can have tabs, this makes sense. But on the other hand every node can have
Open external URLs in a new window
Personally and professionally I think links should open in the same tab, but some clients insist on opening external links in new tabs.
<?php
/**
* Override theme_menu_item_link
* http://api.drupal.org/api/function/theme_menu_item_link/5
*/
function phptemplate_menu_item_link($item, $link_item) {
// make external links open in new windows
Sidebar graphics with links ("promotional badges") the Agaric Drupal way
A note of warning about the length of notes to follow: This is site configuration at the point where it verges on developer documentation, such is the power of Drupal, and there's some outright theming in here too. This article is a reaction to doing sidebar graphics the painfully non-Drupal way.
Theming CCK Views the Agaric Way (with background)
Note that Views and CCK's imagefield module have excellent imagecache integration and you only need these steps if you want very fine-grained control-- in our case, automatically populating the ALT text of the image with the node title.
/admin/build/views/wizard
and
http://agaricdesign.com/note/how-theme-lots-views-agaric-way
and then a little
<?php
print '
';
If you think like we do you'll have something like this in template.php:
<?php
/**
* Theme views invoked by view-specific callbacks (see below).
*/
function phptemplate_views_template($template, &$view, &$nodes, &$type) {
$fields = _views_get_fields();
$taken = array();
// Set up the fields in nicely named chunks.
foreach ($view->field as $id => $field) {
Administration menu initial settings
For the necessary admin_menu module, I prefer the initial settings to not collapse fields on the modules page
With current initial settings this means unchecking "Apply margin-top to page body" and "Collapse fieldsets on modules page." Instead of going through this step every time this should be rolled into Agaric's basic/base installation profile.
Getting trained by Eclipse PDT: Opening an existing folder of files as a project
So you have a directory structure of a project, say it's a giant site you're taking over, and you want to open it as a project in Eclipse PHP Development Tools (PDT) to be able to use the project-wide search and other cool tools.
How to add users to or edit user passwords for a Subversion repository
add new users to an svn repository:
sudo vi svnrepo/conf/passwd
See what Subversion repository you are drawing from with vi .svn/entries
See from what repository checked out subversion code is from by looking at the entries file in a dot SVN folder:
ben@server:/var/www/drupal-5-live/sites/democraticmedia.ca$ vi .svn/entries
Here is the key line, "https://dev.grassrootsconnection.org/svn/drupal/anderson/trunk/democraticmedia.ca," from this output:
8
dir
1375
vi .svn/entries
Creating a random password... the Drupal way
Lesson of the day: don't reinvent Drupal functions.
<?php
/**
* Generate a really lame random password. This would be cooler with words.
*
* Still, gratitude to Jon Haworth, from whom this code was taken.
* http://www.laughing-buddha.net/jon/php/password/
*/
function changents_tl_au_rand_password($length = 5) {
// start with a blank password
$password = "";
Making a quick random number
Not truly random in some cosmic computer science sense, but good enough for non-mission critical (or rather, nothing for anyone to exploit the not-complete-randomness) uses.
http://www.php-scripts.com/php_diary/122799.php3
<?php
srand(time());
$random = (rand()%9);
?>