July, 2012

Float Problem

Case as below. <div class="non-floated-parent" style="background-color:#333; border:1px solid #900;"> <div class="floated-child" style="float:left; width:200px; height:200px; background-color:#000;"> This is a floated element as "float:left; width:200px; height:200px; background-color:#000;" </div> </div><div class="non-floated-parent" style="background-color:#333; border:1px solid #900;"> <div class="floated-child" style="float:left; width:200px; height:200px; background-color:#000;"> This is a floated element as "float:left; width:200px; height:200px; background-color:#000;" </div> </div> This is a floated element as “float:left; width:200px; height:200px; background-color:#000;” Solution 1. Use The clear fix <div class="non-floated-parent" style="background-color:#333; border:1px solid #900;"> <div class="floated-child" style=" float:left; width:200px; height:200px; background-color:#000;"> This is a floated element as "float:left; width:200px; height:200px; background-color:#000;" </div>   <div style="clear: both; "></div>   </div><div class="non-floated-parent" style="background-color:#333; border:1px solid #900;"> <div class="floated-child" style=" float:left; width:200px; height:200px; background-color:#000;"> This […]

Posted in CSS | Comments Off on Float Problem

Feeds Node Processor

Allow User Name and Email case ‘user_name’: if ($user = user_load_by_name($value)) { $target_node->uid = $user->uid; } break; case ‘user_mail’: if ($user = user_load_by_mail($value)) { $target_node->uid = $user->uid; } break;case ‘user_name’: if ($user = user_load_by_name($value)) { $target_node->uid = $user->uid; } break; case ‘user_mail’: if ($user = user_load_by_mail($value)) { $target_node->uid = $user->uid; } break; public function getMappingTargets() { $targets[’user_name’] = array( ‘name’ => t(’LID’), ‘description’ => t(’The Drupal LID of the node author.’), ); $targets[’user_mail’] = array( ‘name’ => t(’User email’), ‘description’ => t(’The Drupal email address of the node author.’), );public function getMappingTargets() { $targets[‘user_name’] = array( ‘name’ => t(‘LID’), ‘description’ => t(‘The Drupal LID of the node author.’), ); $targets[‘user_mail’] […]

Posted in Drupal | Comments Off on Feeds Node Processor

Feeds User Processor

protected function entitySave($account) { if ($this->config[’defuse_mail’]) { $account->mail = $account->mail . ‘_test’; } $account->roles = $account->roles + array_filter($this->config[’roles’]); //bikim user_save($account, (array) $account); if ($account->uid && !empty($account->openid)) { $authmap = array( ‘uid’ => $account->uid, ‘module’ => ‘openid’, ‘authname’ => $account->openid, ); if (SAVED_UPDATED != drupal_write_record(’authmap’, $authmap, array(’uid’, ‘module’))) { drupal_write_record(’authmap’, $authmap); } } } protected function entitySave($account) { if ($this->config[‘defuse_mail’]) { $account->mail = $account->mail . ‘_test’; } $account->roles = $account->roles + array_filter($this->config[‘roles’]); //bikim user_save($account, (array) $account); if ($account->uid && !empty($account->openid)) { $authmap = array( ‘uid’ => $account->uid, ‘module’ => ‘openid’, ‘authname’ => $account->openid, ); if (SAVED_UPDATED != drupal_write_record(‘authmap’, $authmap, array(‘uid’, ‘module’))) { drupal_write_record(‘authmap’, $authmap); } } } protected function entityLoad(FeedsSource $source, […]

Posted in Drupal | Comments Off on Feeds User Processor

Create augmentative user id

email_registration.module if (empty($names)) { $new_name = ‘CUSTOM-NUMBER-FOR-USER-ID’; if ((bool) db_query("SELECT 1 FROM {users} WHERE uid <> :uid AND LOWER(name) = LOWER(:new_name)", array(’:uid’ => $account->uid, ‘:new_name’ => $new_name))->fetchField()) { $name_idx = db_query_range("SELECT SUBSTRING_INDEX(name,’X’,-1) FROM {users} WHERE name REGEXP :search ORDER BY CAST(SUBSTRING_INDEX(name,’X’,-1) AS UNSIGNED) DESC", 0, 1, array(’:search’ => ‘^’ . $new_name . ‘[0-9]+$’))->fetchField(); $new_name .= sprintf(’%010u’,($name_idx + 1)); } }if (empty($names)) { $new_name = ‘CUSTOM-NUMBER-FOR-USER-ID’; if ((bool) db_query("SELECT 1 FROM {users} WHERE uid <> :uid AND LOWER(name) = LOWER(:new_name)", array(‘:uid’ => $account->uid, ‘:new_name’ => $new_name))->fetchField()) { $name_idx = db_query_range("SELECT SUBSTRING_INDEX(name,’X’,-1) FROM {users} WHERE name REGEXP :search ORDER BY CAST(SUBSTRING_INDEX(name,’X’,-1) AS UNSIGNED) DESC", 0, 1, array(‘:search’ => ‘^’ . $new_name . […]

Posted in Drupal | No Comments »

User Custom Field in Node

Case[Node] node.tpl.php $node_author = user_load($node->uid); $user_lid = field_get_items(’user’, $node_author, ‘field_user_id’); $user_photo = field_get_items(’user’, $node_author, ‘field_user_photo’);$node_author = user_load($node->uid); $user_lid = field_get_items(‘user’, $node_author, ‘field_user_id’); $user_photo = field_get_items(‘user’, $node_author, ‘field_user_photo’); <div class="node-photo"> <?php if ($user_photo): ?> <img src="<?php print image_style_url(’50×50′, $user_photo[0][‘uri’]); ?>" /> <?php endif; ?> </div><div class="node-photo"> <?php if ($user_photo): ?> <img src="<?php print image_style_url(’50×50′, $user_photo[0][‘uri’]); ?>" /> <?php endif; ?> </div> <div class="node-lid"> <?php render($user_lid[0][‘value’]) ?> </div><div class="node-lid"> <?php render($user_lid[0][‘value’]) ?> </div> Case[Comment] comment.tpl.php $comment_author = user_load($comment->uid); $user_lid = field_get_items(’user’, $comment_author, ‘field_user_id’); $user_photo = field_get_items(’user’, $comment_author, ‘field_user_photo’);$comment_author = user_load($comment->uid); $user_lid = field_get_items(‘user’, $comment_author, ‘field_user_id’); $user_photo = field_get_items(‘user’, $comment_author, ‘field_user_photo’); <div class="comment-photo"> <div class="comment-photo"> <?php if ($user_photo): ?> <img src="<?php print image_style_url(’50×50′, […]

Posted in Drupal | Comments Off on User Custom Field in Node

How to add a term name to body class

Put these codes in template.php function taxonomy_node_get_terms($node, $key = ‘tid’) { static $terms;   if (!isset($terms[$node->vid][$key])) { $query = db_select(’taxonomy_index’, ‘r’); $t_alias = $query->join(’taxonomy_term_data’, ‘t’, ‘r.tid = t.tid’); $v_alias = $query->join(’taxonomy_vocabulary’, ‘v’, ‘t.vid = v.vid’); $query->fields( $t_alias ); $query->condition("r.nid", $node->nid); $result = $query->execute(); $terms[$node->vid][$key] = array(); foreach ($result as $term) { $terms[$node->vid][$key][$term->$key] = $term; } } return $terms[$node->vid][$key]; }function taxonomy_node_get_terms($node, $key = ‘tid’) { static $terms; if (!isset($terms[$node->vid][$key])) { $query = db_select(‘taxonomy_index’, ‘r’); $t_alias = $query->join(‘taxonomy_term_data’, ‘t’, ‘r.tid = t.tid’); $v_alias = $query->join(‘taxonomy_vocabulary’, ‘v’, ‘t.vid = v.vid’); $query->fields( $t_alias ); $query->condition("r.nid", $node->nid); $result = $query->execute(); $terms[$node->vid][$key] = array(); foreach ($result as $term) { $terms[$node->vid][$key][$term->$key] = $term; } } return $terms[$node->vid][$key]; […]

Posted in Drupal | Comments Off on How to add a term name to body class

Vim 基本操作まとめ

カーソル移動 h, j, k, l [左下上右]へ移動 gj 表示行単位で移動(↓) gk 表示行単位で移動(↑) ^ 行頭へ移動 $ 行末へ移動 % 対応する括弧へ移動 Vimにおける、基本操作のチートシート。だいぶ使えるようになってきたのでメモっておきます。 モード切替 i 挿入モード(カーソル位置から) a 挿入モード(カーソルの後から) : コマンドラインモード v ビジュアルモード C-[ ノーマルモード <ESC> ノーマルモード Vimは複数のモードを持ち、これらを切り替えることで全ての編集機能を扱えるようになっている。以後はノーマルモードを基本として紹介します。ちなみに「C-a」で「Ctrl+a」みたいな感じです。よろしく! 保存&終了 :e ファイルを開く。新規作成もコレ(:editと同じ) :w 保存(:w!で強制的に保存) :q 終了(:q!で編集結果を破棄して終了) :f ファイル名を変更して編集を続ける(:fileと同じ) ZZ 保存して終了(:wqと微妙に同じ) ZQ 保存せずに終了 C-z 中断(fgで復帰。:suspendと同じ) コピー&ペースト [数値]dd 行をカット [数値]yy 行をコピー P ペースト(カレント行) p ペースト(カーソルの下) 取り消し&やり直し u 取り消し(Undo) U 行に対して行った変更の全てを取り消す C-r やり直し(:redoと同じ) マクロ(キーのレコード) qa[操作]q aレジスタにコマンドを記録 qA[操作]q aレジスタにコマンドを追記 [数値]@a aレジスタのコマンドを再生 @@ 直前に実行したレジスタを再生 選択 v 選択開始 V 行選択 C-v 矩形選択 gv 直前の選択範囲を再選択 検索 /[文字列] 前方検索 ?[文字列] 後方検索 # カーソル位置の単語を前方検索 * カーソル位置の単語を後方検索 n 次の候補 N 前の候補 gd カーソル位置のローカル宣言を検索 gD カーソル位置のグローバル宣言を検索 置換 :% s/from/to/g %でページ全体 :32,40 s/from/to/g 32行目から40行目までの間で実行 :/search/s//replace/g 検索候補から置換する memo1: 置換の構文 → :[範囲]s/[検索語句]/[置換語句]/[オプション] […]

Posted in Linux | Comments Off on Vim 基本操作まとめ