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麆鳉鳈齋齈黑齡鶝龤鷫

评论 (写第一个评论)