27/03/2012

Drupal7: tabledrag.js error

Drupal version:
D7X

--

Problem:
tabledrag.js not working in some shared hostings.

--

Workaround:
Go to /admin/config/development/performance
Check the Aggregate JavaScript files.

08/12/2011

Ubuntu 11.10: FTP, vsftpd & Virtual Akun

Instal vsftpd & libpam-pwdfile

Sunting /etc/vsftpd.conf

listen=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
connect_from_port_20=YES
chroot_local_user=YES
secure_chroot_dir=/var/run/vsftpd/empty
pam_service_name=vsftpd
rsa_cert_file=/etc/ssl/private/vsftpd.pem
virtual_use_local_privs=YES
guest_enable=YES
user_sub_token=$USER
local_root=/var/www/situs/$USER
hide_ids=YES

Sunting /etc/pam.d/vsftpd

# Customized login using htpasswd file
auth required pam_pwdfile.so pwdfile /etc/vsftpd.passwd
account required pam_permit.so

Reka virtual akun

sudo htpasswd -cd /etc/vsftpd.passwd virtualAkun

Reka direktori baru

sudo mkdir /var/www/situs/virtualAkun

Sunting permisi/kepemilikan

sudo chown ftp:ftp /var/www/situs/virtualAkun
sudo chmod +w /var/www/situs/virtualAkun

Daur vsftpd

sudo service vsftpd restart

Coba~coba

is@oneiric:~$ ftp 127.0.0.1
Connected to 127.0.0.1.
220 (vsFTPd 2.3.2)
Name (127.0.0.1:is): webDevel
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>

Catatan:
Backup, backup & backup!
Ubah "virtualAkun" sesuai selera

Sumber bacaan:
https://help.ubuntu.com/11.10/serverguide/C/ftp-server.html
http://howto.gumph.org/content/setup-virtual-users-and-directories-in-vsftpd

03/12/2011

Drupal 7: Print Block in tpl.php

<?php
  print views_embed_view($name = 'blockName', $display_id = 'blockId');
?>

or

<?php
  $block = module_invoke('blockType', 'block_view', 'blockId');
  print render($block); ?>
?>

or

<?php
  $block = block_load('block', id);
  $output = drupal_render(_block_get_renderable_array(_block_render_blocks(array($block))));
  print render($output);
?>

15/11/2011

Ubuntu 11.10: Problem! I Solved

Ikon removeable media (USB flash, CD dll.) tak nongol di desktop.
run command

gsettings list-recursively | grep nautilus | less

if

org.gnome.nautilus.desktop volumes-visible false

run command

gsettings set org.gnome.nautilus.desktop volumes-visible true

endif

03/08/2011

Drupal: Get User Role(s)

global $user;
if (in_array('user role', $user->roles)) {
     //do stuff here
}

multiple role checking:

if (in_array(array('user', 'role'), $user->roles));

16/03/2011

Ubuntu: Partisi Khusus untuk Data

0. Reka partisi untuk data[0].

1. Identifikasi partisi dimaksud.
1.0. device:

sudo fdisk -l

Output:

Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0003be96

Device  Boot Start End Blocks  Id System
/dev/sda1 * 1 2611 20966400 83 Linux
/dev/sda2  2611 2937 2616320  83 Linux
/dev/sda3  9596 9730 1075200  82 Linux swap/Solaris

Dalam kasus ini partisi dimaksud adalah /dev/sda2

1.1. UUID dan tipe/filesystem (perhatikan /dev/sda2).

sudo blkid

Output:

/dev/sda1: UUID="dcdfc3c2-c22d-4d06-a6c9-f069a490b7ef" TYPE="ext4" 
/dev/sda2: UUID="ad9dc100-2d82-4349-b32f-32b22d67fe76" TYPE="ext4" 
/dev/sda3: UUID="8e85afaf-0cd1-46c9-b71e-344c745e2864" TYPE="swap"

2. Reka 3 direktori baru

sudo mkdir /data
sudo mkdir /data/user
mkdir ~/data

3. Sunting file /etc/fstab[1], jangan lupa backup:

sudo cp /etc/fstab /etc/fstab_backup
sudo nano -w /etc/fstab

3.0. Imbuh baris seperti berikut:

UUID=ad9dc100-2d82-4349-b32f-32b22d67fe76 /data  ext4 defaults 0 0
/data/user     /home/user/data none bind

3.1. Save dan exit

^O ^X

4. Mount ulang partisi

sudo mount -a
sudo mount -B /data/user /home/user/data

4.0. Reka file dalam direktori ~/data, harusnya hasilnya sama antara

ls -al ~/data
ls -al /data/user

5. Sunting permisi direktori dan file

sudo chown -R owner:owner /data/user
sudo chmod 755 /data/user
cd /data/user
sudo find . -type f -exec chmod 644 {} \;
sudo find . -type d -exec chmod 755 {} \;

6. Enjoy

Catatan:
Direktori data bisa diganti dengan nama lain.
Ubah direktori user sesuai nama usernya.

Bahan bacaan:
[0] https://help.ubuntu.com/community/HowtoPartition
[1] https://help.ubuntu.com/community/Fstab

11/03/2011

Blogger: Manipulasi Jumlah Post per Halaman Label

# Backup, backup, backup
# Edit HTML, klik "Expand Widget Templates"
# Sunting baris

expr:href='data:label.url'

# menjadi seperti

expr:href='data:label.url + "?max-results=<jumlah>"'

Catatan:
Ganti <jumlah> dengan angka yang diinginkan

Bahan bacaan:
http://www.w3.org/TR/REC-xml

10/03/2011

Drupal 7: jQuery Backstretch

/*
* jQuery Backstretch
* http://srobbin.com/jquery-plugins/jquery-backstretch
* Add a dynamically-resized background image to the page
* Copyright (c) 2010 Scott Robbin (srobbin.com)
* Dual licensed under the MIT and GPL licenses.
*/

# Salin jQuery bawaan Drupal atau unduh dari situs jQuery

cp path/to/core/jquery.js path/to/theme/

# Unduh jQuery Backstretch

cd path/to/theme
wget https://download.github.com/srobbin-jquery-backstretch-<versi>.tar.gz
tar -xvzf srobbin-jquery-backstretch-<versi>.tar.gz

# Implementasi
## Global

nano -w path/to/theme/<file>.info

scripts[] = theme_path/to/<jquery>.js
scripts[] = theme_path/to/<jquery_backstretch>.js
scripts[] = theme_path/to/<jquery_backstretch_snippet>.js

## Lokal (contoh untuk konten tipe article)

nano -w path/to/theme/template.php

function template_preprocess_node(&$variables) {
  // further restrict to just 'article' node types
  if ($variables['node']->type == 'article') {
    // jQuery
    drupal_add_js('base_path/to/theme/jquery/js', 'file');
    // jQuery Backstretch
    drupal_add_js('base_path/to/theme/jquery/backstretch/js', 'file');
    // jQuery Backstretch snippet
    drupal_add_js('
      jQuery(document).ready(function () {
        $.backstretch("base_path/to/theme/background/image", {speed: <0~500>});
      });', array(
        'type' => 'inline',
        'scope' => 'footer',
        'weight' => 20
      )
    );
  }
}

# Cuci registry & nikmati!

Catatan:
Ubah semua <text> sesuai nilai sesungguhnya

Bahan bacaan:
http://drupal.org/node/171205#scripts
http://drupal.org/node/756722
common.inc/function/drupal_add_js/7

08/03/2011

GIMP: Efek Vintage

Credit: Ricardo Liberato (All Gizah Pyramids) [CC-BY-SA-2.0], via Wikimedia Commons

# Auto enhanchment

colors > auto > stretch contrast
colors > levels: auto

# Framming

select > all; shrink: 75; feather: 300; Invert

layer > new layer: transparent

FG ffffff, BG 000000
blandtool (L) > FG to BG (RGB)
shape: radial

add gradient from center to selection edge of image
mode: overlay
image > flatten image
select > none

colors > curves: S shape

# Create 3 new layers

newlayer: color fbf2a3, mode multiply, opacity 60
newlayer#1: color e865b3, mode screen, opacity 20
newlayer#2: color 0949e9, mode screen, opacity 17
image > flatten image

# Gradient (optional)

duplicate layer, mode overlay, opacity 50%
FG 000000, BG ffffff
blandtool (L) > FG to BG (RGB)
colors > map > gradient map
image > flatten image

# Reduce saturation

color > hue-saturation > saturatin > -30

Reading material:
http://docs.gimp.org/2.6/en/

07/03/2011

Drupal 7: Mengubah Tipe Penanggalan

Drupal menyediakan empat tipe penanggalan: short, medium, long dan custom. Tipe medium merupakan default-nya. Sayang tak ada cara lebih mudah selain melalui pendekatan "theme override" untuk mengubahnya.

# Bila belum ada, reka file "template.php" di direktori induk theme terkait.

## Untuk node
# Salin "template_preprocess_node(&$variables)" dari file "modules/node/node.module" (sekitar baris ke-1440) ke dalam file "template.php".

# Cari dan ubah

$variables['date'] = format_date($node->created);

# menjadi (untuk tipe short, medium atau long)

$variables['date'] = format_date($node->created, '<tipe>');

# atau (untuk tipe custom)

$variables['date'] = format_date($node->created, '<tipe>', '<format>');

## Untuk comment
# Salin "template_preprocess_comment(&$variables)" dari file "modules/comment/comment.module" (sekitar baris ke-2263) ke dalam file "template.php".

# Cari dan ubah

$variables['created'] = format_date($comment->created);
$variables['changed'] = format_date($comment->changed);

# menjadi (untuk tipe short, medium atau long)

$variables['created'] = format_date($comment->created, '<tipe>');
$variables['changed'] = format_date($comment->changed, '<tipe>');

# atau (untuk tipe custom)

$variables['created'] = format_date($comment->created, '<tipe>', '<format>');
$variables['changed'] = format_date($comment->changed, '<tipe>', '<format>');

## Untuk semua
# Ubah <tipe> dan <format> sesuai selera.

# Demikian kira-kira ..

Catatan:
Untuk <tipe> pilih salah satu: short, medium, long atau custom.
Untuk <format> gunakan standard PHP.
Gunakan hanya tag pembuka PHP di dalam file template.php.

Bahan bacaan:
template_preprocess_node/7
template_preprocess_comment/7
format_date/7
en/function.date.php
node/1075692

27/02/2011

Web Devel: Transparent Background Image

For transparent image[0]:

New layer: 1px (any color)
opacity: +/- 70%
Image: merge visible layers
Save as: PNG; select all except creation time & comment

For HTML & CSS to get the ball rolling:

<div id="outer">
  <div id="inner"></div>
</div>

#outer {
  background-image: any-background-image.jpg;
}
#inner {
  background-color: transparent;
  background-image: transparent-image.png;
}

Notes:
[0] Done in GIMP

See also:
http://docs.gimp.org/en/gimp-image-combining.html
http://www.w3schools.com/css/css_background.asp

11/02/2011

Drupal 7: Manipulasi "Add new comment"

Hapus link "Add new comment" dari teaser atau bila form komen ditampilkan di halaman sama.

Salin node.tpl.php ke direktori theme terkait, lalu sunting.

Ubah baris

<?php print render($content['links']); ?>

Menjadi

<?php
  // Remove the "Add new comment" link on the teaser page or if the comment
  // form is being displayed on the same page.
  if ($teaser || !empty($content['comments']['comment_form'])) {
    unset($content['links']['comment']['#links']['comment-add']);
  }
  // Only display the wrapper div if there are links.
  $links = render($content['links']);
  if ($links):
?>
  <div class="link-wrapper">
    <?php print $links; ?>
  </div>
<?php endif; ?>

Sumber bacaan:
http://drupal.org/project/bartik

05/12/2010

Ubuntu: Setup DNS Manual


sudo nano -w /etc/resolv.conf
nameserver x.x.x.x
nameserver x.x.x.x


sudo cp /etc/resolv.conf /etc/resolv.conf.auto


sudo nano -w /etc/dhcp3/dhclient.conf
prepend domain-name-servers x.x.x.x,x.x.x.x;


sudo ifdown eth0 && sudo ifup eth0

catatan:
ifconfig #cari tahu IP address
cat /etc/resolv.conf #cari tahu DNS
Ganti x dengan DNS sesuai selera misal: Google public DNS, OpenDNS dll ..