
Weblog
Drupal. How to use an image field from the profile node instead of user picture (avatar)
I've recently had to make default pictures for user pictures,
but they had to be defferent for different user roles.
I used the module content_profile
and created two profile content types for Student and Teacher roles.
So I decided to change a user picture derectly in my theme.
I change the preprocess function starsensei_preprocess_user_picture from user module
in template.php:
<?php
function mytheme_preprocess_user_picture(&$variables) {
$variables['picture'] = '';
$account = $variables['account'];
$user = user_load(array('uid' => $account->uid));
$roles = $user->roles;
$profile = '';
if (is_array($roles)) {
if (array_search('student', $roles)) {
$profile = 'studentprofile';
} else if (array_search('sensei', $roles)) {
$profile = 'profile';
}
}
if (!empty($profile)) {
$node_profile = content_profile_load($profile, $account->uid);
$field_photo = content_fields('field_photo', $profile);
$picture = content_view_field($field_photo, $node_profile);
} else {
// from default preprocess_user_picture:
if (!empty($account->picture) && file_exists($account->picture)) {
$picture = file_create_url($account->picture);
}
else if (variable_get('user_picture_default', '')) {
$picture = variable_get('user_picture_default', '');
}
if (isset($picture)) {
$alt = t("@user's picture", array('@user' => $account->name ? $account->name : variable_get('anonymous', t('Anonymous'))));
$variables['picture'] = theme('image', $picture, $alt, $alt, '', FALSE);
if (!empty($account->uid) && user_access('access user profiles')) {
$attributes = array('attributes' => array('title' => t('View user profile.')), 'html' => TRUE);
$variables['picture'] = l($variables['picture'], "user/$account->uid", $attributes);
}
}
//
}
$variables['picture'] = $picture;
}
?>Sushi master class
I'm not a cook, but I've recently fallen in love with creating sushi for my husband and daughter.
I found some recipes in the Inet, but I coudn't find any good video tutorials.
However I came across one wonderful video master class yesterday - it was taken by one russian proffecional photographer (his blog with fantastic photos - http://sergeydolya.livejournal.com/)
in the USA.
Here the videos:
This is one of the best Sushi restaurants in Las Vegas.
And here you'll find marvelous photos from this restarant about creating sushi - http://sergeydolya.livejournal.com/114199.html
Drupal 6. Alter links
How to remove unnecessary links from the group of links under node.
How to change Description textfield for filefield to textarea
This is a little snippet for Drupal6 for changing a textfield to a textarea
in the Description field of the CCK file field (filefield module).
By default, you can enable Description field, but that will be a textfield input with 128 charecters length,
but already two customes have asked me to make this field longer, because this field is shown
under images in the lightbox box.
<?php
variable_set('filefield_description_length', 300);
variable_set('filefield_description_type', 'textarea');
?>Although the author of this module use variables,
he doesn't give the settings form for them.
How to add a custom token
It is a snippet - how to create custom tokens for specific replacements that can improve other modules relying on Token.
The Magic Lake Seliger
There is a gorgeous place in the middle of Russia,
that is called Lake Seliger, and is also known
as "The Pearl of Russia", and that is an absolutely suitable name.
This is the place, where the main Russian river Volga is born
from tiny brook with the help of thousands of springs.
There I can relax and be closer to nature.
No! not just closer, I can be with nature.
It seems to me I can sit on the sand, on any tiny island,
that has got lost among thousands of other such islands,
surrounded by splendid pines,
and admire the scenery of a marvellous sunset
or just listen to the silence of lake.
This is a place where white clouds are mirrored in the surface of blue water,
where in early summer nights last less than an hour.
It may be stormy as well as absolutely calm.
Meanwhile it doesn't matter what the weather is like now.
Actually, Seliger is not really one lake -
here you'll find plenty of huge and tiny lakes and islands,
magic forest lakes with crystal pure water.
Only one thing can disturb a very gentle person – mosquitoes!
Here is their home :) but not me.
Every summer I look forward to going to my favorite place in the world.
Drupal Google maps. I choose the Simplest gmap
The common task is:
- add location to a node by pointing it on the google map, highly desirable with cck field
- create maps with groups of node on one map with views.
I worked with GMap and location,
I saw at the newer module Google Maps Tools as well,
but when I've found Simplest gmap module I understood that is really what I need.
Gallerix: photogallery for Drupal - my notes
Where are a lot of modules for creating photo galleries with Drupal,
including third-party integration modules - like Gallery2.
Gallerix - that is rather small gallery for photo albums.
However I don't like this module very much,
fortunately, maintainers are going to rewrite it soon.
In my opinion, more flexible way to create photo gallery is just using CCK fields with views:
filefield + imagefield + imagecache + views + lightbox2 (или thickbox)



