1.3 Drupal前端培训

龳龱龮龫龪龨龦龣龢龳龠龝龛龗龖龓龏龨龎龊image style龖齳龣

齲龱齯齬齩齦齥齣齠龖齜齚齗齖齳齔齐齎

test 齜齚齌齈齥齣齇齃龨齁齀鼽鼹龨鼷鼵鼲page鼭鼬齌齈鼪鼨鼦鼤龨鼠鼞鼛龖鼵齌齈鼙鼘鼗header齗footer鼆鼄

test_content 齜齚黽黼齌齈齥齣齇齃龨齁齀鼽鼹龨鼷鼵鼲黽黼鼭鼬齌齈鼪鼨鼦鼤龨鼠鼞鼛龖鼵齌齈鼙黺鼘鼗header齗footer鼆鼄

test_ajax_url ajax黮齠齥齣齇齃龨黬黩黥黣黡黟黛黗黮黔齳鼙齐黐黎黊黗齖齳齔鼪鼨齥齣

黉龱齯齬龪黆黂麾龖龢龳齐齎

黬麻麺麹麷麶麴麲龪黆黂麾龖齇麮龨鼷齦黥黣麫麨龳齦龢龳龖齐齎齯齬黂麾龪黆龖麦麣龨龳麢黬黩麞麺齠js麚麖麒龪黆黂麾龖麎麌龨麊麈麆麄麫麨鼷麃龳齦齐齎龨齐黐黂麾齳齔麀鹿龨黊黗fid

鹼龱龠鹹龦龣鹸齠webfont

龎龊龠鹹黂麾齳龣

鹮龱龠鹹龛龗齗黂麾鹫鹪龨黂麾鹩鹨鹦鹥

鹦鹥鹢鹞鹝鹜龖龠龝鹛鹗齠jpg龨鹖鹢鹕龊龖鹛鹗png龨鹓...

鹍龱鹋齇鹇鹆鹂鹀鸿鸻鼪鼨鸷鸶齥齣

麀鸲鸯黩鸫黬黩鸩鸦鼄鸣龨鸟鸛黬黩鸗鸖龳鸓龨鸏齐鸌鸈鸄鹂鹀鸷鸶鸿鸻鸁麚鷽

鷻龱鷸齠齚鷴鼲鷱鼽鷮鷬鷩css麃鹪

鷥鷤鷣鷢麃鹪鷤btn, btn-default, btn-primary, btn-danger, btn-disable

鷙龱齯齬鷤pager.php, table龖html麃鷕

鷔鷓鼄齜齗鷒鹫龨麊麈鼠鼞鼵齠drupal齯齬龖麮鷐鷏鷍龖龨鷊黣黬黩龖html鷇鷃麲麀鷂龳鶾鷽

鶻.php齌齈鶹鷐

1.齌齈鶳龣

麊麈鷓黬黩麫麨龖齌齈黂麾龨麲鶯鶮鶪齌齈龖黥齠鶳龣鶨鶥龨鶡齳齔龖鶟鶜鶚鶙黬黩麚鶖鷽

/**
 * @file
 * 我的项目经历页面
 *
 * 可用变量:
 * $user_display_name 用户姓名
 * $user_avatar_url 用户头像文件地址
 * ......
 */

2.print

鷏鷍鶳龣

<?php print $user_name; ?>

3.if else endif

鵦麾鵣鵡鷏鷍

<?php if ($front_page): ?>
  <a href="">首页</a>
<?php else: ?>
  <a href="">不是首页</a>
<?php endif; ?>

4.foreach

鵐鸿齳鷬鷏鷍

<?php foreach ($project_lable as $tag): ?>
  <span><?php print $tag->name; ?></span>
<?php endforeach; ?>

5.drupal_add_css

drupal_add_css(path_to_theme() . '/css/cropper.min.css'); 加载css文件

6.drupal_add_js

drupal_add_js(path_to_theme() . '/js/cropper.js'); 加载js文件
drupal_add_js(array('profile' => array('uid' => $uid)), 'setting'); 定义js变量

7.drupal_add_library

鵈鵇鶟鴷鴵

drupal_add_library('common', 'angular');

8.include

鼘鼗黂麾

include path_to_theme() . "/templates/html/footer.php";

9.url

鷏鷍鹂齜齇齃

<?php print url(''); ?> // 首页
<?php print url('project_list'); ?> // 项目列表页
<?php print url('user/' . $user->uid); ?> // 用户主页

10.file_create_url

鷏鷍黂麾齇齃鴨path_to_theme() 鴦鴤鴢黬鴭鴟鴜鴙鴗

<?php print file_create_url(path_to_theme() . '/images/example.jpg'); ?>

11.switch

switch 鶹鴕齠鴒鴑鴒黺鴏鵦麾鴍鼨黺鴏鴊鶜

<?php
  $fa_icon_file_type = '';

  switch ($value['report_file_type']) {
    case 'video':
      $fa_icon_file_type = 'fa-file-video-o';
      break;
    case 'document':
      $fa_icon_file_type = 'fa-file-text-o';
      break;
    case 'audio':
      $fa_icon_file_type = 'fa-file-audio-o';
      break;
    case 'image':
      $fa_icon_file_type = 'fa-file-image-o';
      break;
  }
?>

12.current_path

鴦鴤鴢黬齜齚鳷龢鴜鴙

<?php print current_path(); ?>

鴦鴤鴢黬齜齚鳴鼲鴜鴙

<?php
  global $base_url; // 域名前缀
  
  print $base_url . '/' . current_path();
?>

13.dpm

麆黬黩鳯鳭龳齦鹋齇鸷鸶鸿鸻龖鸷鸶鳪鳧鳣龨黥黣鹸齠devel齌鳡龖dpm麚鳝鳚齌齈黥齠鶳龣鷽

评论 (写第一个评论)