2008/09/27

让你的Firefox支持显示XHTML-MP

最近在开发m.dangdang.com,使用页面标记语言是xhtml-mp,IE是无法显示的。在开发时候需要使用opera来调试(opera还支持wml,wap网站还可以直接看),后来发现Firefox也可以显示xhtml-mp,安装插件即可,https://addons.mozilla.org/zh-CN/firefox/addon/1345

Firefox does not natively support the mime-type
application/vnd.wap.xhtml+xml. This is one of the possible mime-types for XHTML
Mobile Profile. This extension adds support for this mime-type. (The other,
application/xhtml+xml, is supported natively by Firefox.)


Firefox并不原生支持 mime-type为application/vnd.wap.xhtml+xml的页面,本插件使之成为可能。(Firefox是支持XHTML的)。

IE和FF打开网页不显示背景颜色,只显示图片

今天系统很奇怪,IE浏览器不显示网页背景色,图片和动画都正常,打开Firefox试了一下也不行,只有opera可以。上网搜索一下,解决方法如下:

在“控制面板”的“辅助功能选项”下有一“显示”标签,单击该标签后看到“使用高对比度”选项被勾选。清除该选项后,重新启动IE,故障消除。

其实不需要重启浏览器,直接刷新就没有问题了。 原来是自己一不小心修改了控制面板里头的选项。

2008/09/11

cakephp开发笔记(1)

1.如何开发‘xhtml-mp’的页面?
只需在布局模板头部修改成下面这样即可。注意下面第二行的,必须打印,否则php会混淆‘<?’的标记,编译出错。



<?php header('Content-type: application/vnd.wap.xhtml+xml');?>
<?php echo '<?xml version="1.0" encoding="utf-8"?>';?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>...



2.一个构思很酷的函数a()

00210 /**
00211 * Returns an array of all the given parameters.
00212 *
00213 * Example:
00214 *
00215 * a('a', 'b')
00216 *

00217 *
00218 * Would return:
00219 *
00220 * array('a', 'b')
00221 *

00222 *
00223 * @return array Array of given parameters
00224 */
00225 function a() {
00226 $args = func_get_args();
00227 return $args;
00228 }


3.我安装cakephp1.2出现的问题


3.1. .php文件无法执行

解决办法:将php的目录添加到系统环境变量中去。

3.2. 找不到php_exif.dll的扩展

原因是必须在php_mbstring.dll之后加载再加载php_exif.dll。php_exif.dll(EXIF 函数库)需要php_mbstring.dll,并且在 php.ini中,php_exif.dll必须在php_mbstring.dll之后加载。


4.cake bake的几个常用方法(cakephp1.2,已将.../cake/console添加windows环境变量)


创建新的应用,名为baz
cake bake baz

创建model(以下均需cmd到目录:D:\wamp\www\cake\baz(windows))
cake bake model [model name]

创建controller
cake bake controller Users

使用脚手架。额外创建:index, add, view, edit, and delete方法
cake bake controller Users scaffold

带有admin_index, admin_add, admin_view, admin_edit and admin_delete的脚手架
cake bake controller Users scaffold admin

创建视图
cake bake view Users


5.cakephp中取消方法vendor(),改为App::import('Vendor' , '...');

Description

The code I had before was

vendor('Swift');
vendor('EasySwift');
vendor('Swift/Connection/SMTP');
But the latest nightly told me "(vendor) Deprecated, see App::import('Vendor', '...');". So I modified my code to say

App::import('Vendor', 'Swift');
App::import('Vendor', 'EasySwift');
App::import('Vendor', 'Swift/Connection/SMTP');
Unfortunately, the classes no longer loaded. I did some poking around and it seems that App::import('Vendor', ...) doesn't know not to inflect the file names its given.

cakephp生成URL利器:Router::url()

cakephp版本为1.2。

在cakephp中,$html->link() , $html->image() 等方法的第二个参数均为url,都调用了Router::url($url = null, $full = false)。

常见用法:
1.生成url。
假设网站url路径是 http://www.example.com/project-text/。那么下面三者产生的url效果是相同的。
Router::url( array('controller'=>'category' , 'action'=>'list' , $params1, $params2 ) );
Router::url( '/category/list/params1/params2' );
Router::url( 'http://www.example.com/project-text/category/list/params1/params2' );

url均为 http://www.example.com/project-text/category/list/params1/params2' ,前两者产生的均为相对路径,第三个为全路径,需要生成完全路径只需将url()中的第二个参数设为true即可。

2.其他
Router::url( 'javascript:alert("s")' );

Router::url( 'mailto:bit.kevin@gmail.com' );