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麣鳿鳽齈齆黮齛鷄龦鸝

评论 (写第一个评论)