Tagged with " drupal"
Oct 11, 2013 - 前端    No Comments

clearfix的前世今生

在很久很久以前,清除浮动这个问题一直困扰着我。直到我写出这样一行代码。

.auto_height { 
  height:auto !important; 
  height:100%; 
  min-height:0px; 
  overflow:hidden; 
  _overflow:inherit;
}

这行代码兼容ie6,ie7,firefox2,firefox3。那个年代还没有chrome,还没有css3。我还在用着我的iphone1。那是一个兼容ie6是理所当然的年代。

直到有一天,我遇到了drupal6,发现自己的代码虽然管用,但看上去总是那么的土鳖。那个时候clearfix还不叫clearfix,叫clear-block

/*
** Markup free clearing
** Details: http://www.positioniseverything.net/easyclearing.html
*/
.clear-block:after {
  content: ".";
  display: block;
  height: 0;
  clear: both;
  visibility: hidden;
}

.clear-block {
  display: inline-block;
}

/* Hides from IE-mac \*/
* html .clear-block {
  height: 1%;
}
.clear-block {
  display: block;
}
/* End hide from IE-mac */

看看人家的注释多么的高端洋气!
Read more »

May 9, 2013 - 前端    No Comments

用minify合并,压缩js和css

drupal可以把所有

<?php print $styles ?>
<?php print $scripts ?>

输出的css和js都合并压缩成一个文件以减少http request数量,但有时候项目里的某个页面是一个游离于drupal外的静态页面,js和css是不受drupal管理的,那么如果有合并压缩css和js的需求的时候,就需要用到minify
Read more »

May 8, 2013 - mac    No Comments

mysql localhost vs 127.0.0.1

前几天,再把一个drupal项目导到自己电脑的时候,犯了一个低级错误。解决的过程有点2b,在这里记录一下自己的2b时刻。

一个drupal项目的数据库和站点文件全都导到自己的电脑上后,始终报一个错“No such file or directory”。站点文件的权限也简单粗暴的777了。但始终就是报这个错。上网查了后才知道是mysql.sock这个文件的路径指向不对造成的。需要吧php.ini里3个配置项改对。

首先在终端里执行:

/usr/local/mysql/bin/mysql

这样就进入mysql的命令行模式,然后执行:
Read more »

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="" />
Pages:12»