Browsing "前端"
Mar 12, 2013 - 前端    No Comments

drupal7自定义html层和page层tpl的命名规则

drupal7在tpl的使用上要比drupal6升级很多,最明显的区别就是有了html.tpl.php这个文件,可以很方便的对一些全局性的信息进行管理。
一个标准的html.tpl.php的代码如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
  "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language; ?>" version="XHTML+RDFa 1.0" dir="<?php print $language->dir; ?>"<?php print $rdf_namespaces; ?>>

<head profile="<?php print $grddl_profile; ?>">
  <?php print $head; ?>
  <title><?php print $head_title; ?></title>
  <?php print $styles; ?>
  <?php print $scripts; ?>
</head>
<body class="<?php print $classes; ?>" <?php print $attributes;?>>
  <div id="skip-link">
    <a href="#main-content" class="element-invisible element-focusable"><?php print t('Skip to main content'); ?></a>
  </div>
  <?php print $page_top; ?>
  <?php print $page; ?>
  <?php print $page_bottom; ?>
</body>
</html>

Read more »

Feb 6, 2013 - 前端    No Comments

drupal7输出$user->picture的url

<?php 
  global $user; 
  $fid = $user->picture;
  $file = file_load($fid);
  $uri = $file->uri;
  $path = file_create_url($uri);
?>
<img src="<?php print url($user->picture ? $path : 'sites/default/files/default_images/user-default-picture.jpg'); ?>" alt="" />
Feb 3, 2013 - 前端    No Comments

2个应该加入base.sass的属性

/* 解决chrome 12像素字体大小限制 */
body
  -webkit-text-size-adjust: none

/* 解决link点击后周围一圈虚线的问题 */
a
  blr: expression(this.onFocus=this.close())
  blr: expression(this.onFocus=this.blur())  
a:focus
  -moz-outline-style: none
  outline: none
Nov 14, 2012 - 前端    No Comments

Use Modernizr

modernizr.js是一个可以帮组前端了解浏览器特性,并写出渐进式增强css的js文件。
使用起来非常简单,首先在html的head区加入代码:

<script src="js/modernizr-2.6.2.min.js"></script>

这段代码一定要加在head关门标签前,而不能放在body关门标签前。

然后给html标签加上一个class

<html class="no-js">

其实这个class加不加都可以的,但如果真的碰到不能运行js的浏览器这个class就可以起作用了。

然后在浏览器里打开这个页面,可以看到:

Read more »

Pages:«1234»