Changents

Where in the theme are the tabs printed / giving tabs to admins only

Key words and phrases: 
Drupal tabs local tasks where printed by theme? phptemplate_variables page phptemplate node page tabs give tabs to admins only
Description & Info: 

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

by Benjamin Melançon
Posted on Thu, 2008-08-14 06:06
in

Open external URLs in a new window

Key words and phrases: 
open external URL in new window or tab external link check
Description & Info: 

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

Key words and phrases: 
show graphics in sidebar on certain pages linked to featured sections easily change graphics in specific sidebar block regions
Description & Info: 

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)

Key words and phrases: 
theme views CCK imagefield with imagecache
Description & Info: 

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) {

by Benjamin Melançon
Posted on Sun, 2008-08-03 10:40
in

Administration menu initial settings

Key words and phrases: 
Administration menu
Description & Info: 

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

Key words and phrases: 
Eclipse PDT new PHP project from directory import project from source use existing code for PDT project
Description & Info: 

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

Key words and phrases: 
svn password
Description & Info: 

add new users to an svn repository:

sudo vi svnrepo/conf/passwd

by Benjamin Melançon
Posted on Thu, 2008-07-17 22:12
in

See what Subversion repository you are drawing from with vi .svn/entries

Key words and phrases: 
svn source svn see what repository link is get what subversion repository you are drawing from Where is the location of my svn repos
Description & Info: 

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

Key words and phrases: 
make random password generate pass assorted string of letters php random password generator
Description & Info: 

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 = "";

by Benjamin Melançon
Posted on Sun, 2008-06-01 05:23
in

Making a quick random number

Key words and phrases: 
PHP random digit quick number
Description & Info: 

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);
?>

by Benjamin Melançon
Posted on Sat, 2008-05-31 09:47
in