just photo

Drupal

Drupal. How to use an image field from the profile node instead of user picture (avatar)

Julia 19/01/2010

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;

}

?>

Drupal 6. Разные виды списков для терминов из разных словарей

Julia 16/01/2010

Очень частно нужно выводить содержание разделов, которые относятся к разным словарям по разному.

Т.е. например, для термина из словаря Catalog нужно выводить только короткое содержание соответствующих нодов (node teasers), а для словаря Tags нужно выводить только заголовки,
или например, для Catalog нужно выводить ноды с картинками, а для Tags - без них.

При этом основная страница терминов в Drupal - taxonomy/term/[tid], и по умолчанию показываются в виде ссылок в конце нода.

тэги:

Drupal 6. Alter links

Julia 16/01/2010

How to remove unnecessary links from the group of links under node.

тэги:

How to change Description textfield for filefield to textarea

Julia 15/01/2010
Imagefield with textarea for Description

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

Julia 06/01/2010

It is a snippet - how to create custom tokens for specific replacements that can improve other modules relying on Token.

Drupal 6. Вывод списков в тексте, через запятую

Julia 06/10/2009

Простая задача - выводить непосредственно в тексте какие-либо списки (созданные с помощью views), сформированные автоматически по содержанию сайта.

Ну например - сайт компании, есть страница с описанием услуг компании и в тексте нужно упомянуть партнеров этой компании, есть описание каждого партнера на отдельной странице, список должен формироваться автоматически.

тэги:

Drupal. Ссылка на перевод во view

Julia 25/09/2009

Вроде бы и простая задача - добавить ссылку или ссылки на переводы страницы в списке view,
а сразу и не догадаешься как это сделать во Views 2.
Так как такого поля как ссылка на перевод нет.
Самый простой вариант - показывать короткое содержание (Row style = teaser),
тогда можно включить опцию "показывать ссылки", а в ссылках есть ссылки на переводы.
А что если это не подходит, и список нужно выводить в виде набора полей.

тэги:

Drupal 6. Меню ориентированный сайт

Julia 13/09/2009
Sibling menu в блоке
Submenu в содержании
Hirarchical menu

Создавая сайт на друпал, можно использовать несколько механизмов
формирования главной структуры сайта. Основное - это таксономия и меню.
Однако для многих небольших сайтов таксономия может быть вообще не нужна.
Рассмотрим такой вариант и будет строить структуру сайта только на основе системы Меню.

тэги:

Drupal Google maps. I choose the Simplest gmap

Julia 21/06/2009
CCK field of Simplest Gmap module
Simplest gmap field settings

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

Julia 21/06/2009
та самая галерея Gallerix, которую пришлось настраивать

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)

тэги: