just photo

Weblog

Drupal module Features. Some Tips.

Julia 29/07/2010

Module features is necessary for site builders in order to maintain big projects.

Some tips about this great module:

Doesn't want to be reverted

It happens sometimes that overridden feature pack doesn't want to be reverted,
for example after updating it in another system.

The solution is simple, if this feature pack has views objects.
You just have to flush views cache and try again.

Show views that are overridden

If you have a lot of feature packs with many views in them
and one of views was changed - in the overridden section
you won't understand the name of view that was changed.

To see it - add template file to your theme:
features-admin-components.tpl.php

<div class='clear-block features-components'>
  <div class='column'>
    <div class='info'>
      <h3><?php print $name ?></h3>
      <div class='description'><?php print $description ?></div>
      <?php print $dependencies ?>
    </div>
  </div>
  <div class='column'>
    <div class='components'>
      <?php print $components ?>
      <div class='buttons clear-block'><?php print $buttons ?></div>
    </div>
  </div>
  <?php print $form ?>
 
<?php   
$component
= 'views';
$normal = features_get_normal($name, $component);
$default = features_get_default($name, $component);

foreach (

$normal as $k => $view){
  
$compare = array('normal' => features_var_export($normal[$k]), 'default' => features_var_export($default[$k]));
        if (
_features_linetrim($compare['normal']) !== _features_linetrim($compare['default'])) {
         
$changed .= l($k, 'admin/build/views/edit/'. $k) . '<br/>';
        }
}

if (

$changed) {print '<div><h4>Changed views:</h4>'. $changed .'</div>'; }
?>

</div>
тэги:

Drupal 6. Disable mail field on the user account page

Julia 08/06/2010

If you need to make email field disabled, it won't be anough just make it #disabled.
You have to add the same hidden field:

<?php
function [modulename]_form_alter(&$form, $form_state, $form_id) {
    global
$user;

  switch (
$form_id) {
      case
'user_profile_form':
          if (
$user->uid != 1){
         
// fields must have a hidden field w/ proper value as disabled fields are not submitted.
       
$form['account']['readonly']['mail'] = $form['account']['mail'];
       
$form['account']['readonly']['mail']['#type'] = 'hidden';
           
$form['account']['mail']['#disabled'] = TRUE;
          }
          break;
  }
}
?>

Ubuntu LTS 10.04

Vitaliy 27/04/2010

Ubuntu - Best Linux Distribution
LTS - Long Time Support
Ubuntu 10.04 LTS

Soon!!!

тэги:

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 mytheme_preprocess_user_picture from the user module in the template.php file:

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

Julia 17/01/2010

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 couldn't find any good video tutorials.
However I came across one wonderful video master class yesterday - it was taken by one Russian businessman (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 marvellous photos from this restaurant about creating sushi - http://sergeydolya.livejournal.com/114199.html

тэги:

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.

The Magic Lake Seliger

Julia 23/06/2009
Nilov Monastery
View from the Nilov Monastery belfry

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.

тэги:

Featured articles changed every 24 hours

Julia 21/06/2009
Icon by kylesteed http://kylesteed.com/2009/new-clock-icon/

So here’s the scenario. For one site it’s been decided that every 24 hours they want the frontpage to change featured article.

Is there a way to do two things.

1) Change featured article (homepage only) every 24 hours.
2) Have the ability to change the article to anything they want.

тэги:

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)

тэги: