0

codeigniter

Posted by fishman on 2012 年 5 月 19 日 in cakephp

CodeIgniter.com  网站的Alexa排名高于 cakephp.org , 研究研究。

CodeIgniter is a powerful PHP framework with a very small footprint, built for PHP coders who need a simple and elegant toolkit to create full-featured web applications. If you’re a developer who lives in the real world of shared hosting accounts and clients with deadlines, and if you’re tired of ponderously large and thoroughly undocumented frameworks

0

Q: 如何在javascript中调用php变量?

Posted by fishman on 2012 年 3 月 6 日 in cakephp

Q: 如何在javascript中调用php变量?

A:  javascript是客户端代码,由浏览器解释执行的;php是服务器端代码,在服务器端执行后输出html,javascript代码。

由此可见,可以通过php来生成javascript代码的同时引入php变量。举例如下:

<?php

$message = “这是一个来自 php 的值。”;

echo “<script language=\”JavaScript\” type=\”text/JavaScript\”>;\r\n<!–\r\n alert(‘”.$message.”‘);\r\n–>;\r\n</script>;”;

?>

经调试成功后,javascript调用团购截止时间的代码如下:

<?php

    $year = substr($deal['Deal']['liftoff_time'], 0,4);

    $month = substr($deal['Deal']['liftoff_time'], 5,2);

    $day = substr($deal['Deal']['liftoff_time'], 8,2);

    $hour = substr($deal['Deal']['liftoff_time'], 11,2);

    $minute = substr($deal['Deal']['liftoff_time'], 14,2);

    $second = substr($deal['Deal']['liftoff_time'], 17,2);

    echo “<script language=\”JavaScript\” type=\”text/JavaScript\”>;\r\n “;

//    echo “alert(‘year”.$deal['Deal']['liftoff_time'].”‘);\r\n”;

//    echo “alert(‘year”.$year.”‘);\r\n”;

//    echo “alert(‘”.$month.”‘);\r\n”;

//    echo “alert(‘”.$day.”‘);\r\n”;

//    echo “alert(‘”.$hour.”‘);\r\n”;

//    echo “alert(‘”.$minute.”‘);\r\n”;

//    echo “alert(‘”.$second.”‘);\r\n”;

    echo “$(function () { \r\n”;

    echo “var liftoffTime = new Date($year, $month-1, $day,$hour,$minute,$second); \r\n”;

    echo “$(‘#countdown’).countdown({until: liftoffTime, layout: ‘{dn}{dl}{hn}:{mn}:{sn}’}); \r\n”;

    echo “}); \r\n”;

    echo “</script>”;

?>

0

Q: 如何默认允许执行actions?

Posted by fishman on 2012 年 3 月 6 日 in cakephp

Q: 如何默认允许执行actions?

A:

修改 /app/controllers/pages_controller.php,增加如下方法,可以实现允许全部action的功能。

function beforeFilter()

{

parent::beforeFilter();

//allow all actions of pages controller.

$this->Auth->allow(‘*’);

0

Q: 为什么在/app/views/pages/index.ctp文件中直接调用 $javascript 会出错?

Posted by fishman on 2012 年 3 月 6 日 in cakephp

Q: 为什么在/app/views/pages/index.ctp文件中直接调用 $javascript 会出错?

A:  因为首页是通过  /app/controllers/pages_controller.php 调用的,这个php文件默认的helper 只有 ‘Html’, 修改这个文件,使其变成如下代码:

var $helpers = array(‘Html’,'Javascript’);

这样ctp就可以通过如下代码加载javascript文件了。

echo $javascript->link(‘../theme/mutong365/js/jquery-1.4.4.min’, false);

echo $javascript->link(‘../theme/mutong365/js/jquery-countdown-1.5.8.js’, false);

echo $javascript->link(‘../theme/mutong365/js/mixpanel.js’, false);

echo $javascript->link(‘../theme/mutong365/js/simplemodal.js’, false);

echo $javascript->link(‘../theme/mutong365/js/fancy/jquery.fancybox-1.3.4.pack.js’, false);

下面是加载css文件的代码:

echo $html->css(‘../theme/mutong365/css/jquery.fancybox-1.3.4.css’);

0

Q: 如何在 index.ctp中引入css或者js文件?

Posted by fishman on 2012 年 3 月 6 日 in cakephp

Q: 如何在 index.ctp中引入css或者js文件?

A:

Js文件::

echo $javascript->link(‘/full_calendar/js/jquery-1.5.min’, false);

echo $javascript->link(‘/full_calendar/js/jquery-ui-1.8.9.custom.min’, false);

echo $javascript->link(‘/full_calendar/js/fullcalendar.min’, false);

echo $javascript->link(‘/full_calendar/js/jquery.qtip-1.0.0-rc3.min’, false);

echo $javascript->link(‘/full_calendar/js/ready’, false);

css文件::

echo $html->css(‘/full_calendar/css/fullcalendar’, null, array(‘inline’ => false));

0

Q: 如何更改首页的内容?

Posted by fishman on 2012 年 3 月 6 日 in cakephp

Q: 如何更改首页的内容?

A:  Editing this Page

To change the content of this page, edit: D:\eclipse-php-helios-SR1-win32\eclipse\workspace\test\app\views\pages\home.ctp.

To change its layout, edit: D:\eclipse-php-helios-SR1-win32\eclipse\workspace\test\app\views\layouts\default.ctp.

You can also add some CSS styles for your pages at: D:\eclipse-php-helios-SR1-win32\eclipse\workspace\test\app\webroot\css

修改 /app/config/routes.php

Router::connect(‘/’, array(‘controller’ => ‘pages’, ‘action’ => ‘display’, ‘index’));

将home 修改为 index。

然后创建 /app/views/pages/index.ctp 文件,这样就可以使 index.ctp的成为网站首页。

0

Q: 如何实现时间倒计时功能

Posted by fishman on 2012 年 3 月 6 日 in cakephp

 Q: 如何实现时间倒计时功能 countdown timer to any date?

A:  http://keith-wood.name/countdown.html

mutong365网站的具体实现方式如下:

 

<script type=”text/javascript”>

$(function () {

var liftoffTime = new Date();

liftoffTime = new Date(liftoffTime.getFullYear(), 2, 22,16,35,00);

//$(‘#countdown’).countdown({until: liftoffTime, layout: ‘{dn} {dl} {hn} {hl} {mn} {ml} {sn} {sl}’});

$(‘#countdown’).countdown({until: liftoffTime, layout: ‘{dn}{dl}{hn}:{mn}:{sn}’});

});

</script>

 

ps: http://keith-wood.name/index.html 这个网站有不少jquery的插件,可以考虑使用。

0

Q: How to display the current user?

Posted by fishman on 2012 年 3 月 6 日 in cakephp

Q: How to display the current user?

A:  //In a particular controller or /app/app_controller.php to apply to all:

 

function beforeRender(){

$this->set(‘currentUser’, $this->Auth->user());

}

//In the view:

<?php

echo( $currentUser['User']['username'] . ‘ (‘ . $currentUser['User']['id'] . ‘)’ );

?>

0

Q: 如何自定义form中的css?

Posted by fishman on 2012 年 3 月 6 日 in cakephp

Q: 如何自定义form中的css?

A:  http://book.cakephp.org/#!/view/1390/Automagic-Form-Elements

<?php

$options = array(

‘label’ => ‘Update’,

‘value’ => ‘Update!’,

‘div’ => array(

‘class’ => ‘glass-pill’,

)

);

echo $this->Form->end($options);

 

Will output:

<div class=”glass-pill”><input type=”submit” value=”Update!” name=”Update”></div>

See the API for further details.

0

Q: 网站中文字体如何设置?

Posted by fishman on 2012 年 3 月 6 日 in cakephp

 Q: 网站中文字体如何设置?

A:  设置成微软雅黑。

修改/app/webroot/theme/mutong365/css/tds.css文件中所有的font-family。

font-family: Microsoft YaHei,

Windows的一些:

黑体:SimHei

宋体:SimSun

新宋体:NSimSun

仿宋:FangSong

楷体:KaiTi

仿宋_GB2312:FangSong_GB2312

楷体_GB2312:KaiTi_GB2312

微软雅黑体:Microsoft YaHei

装Office会生出来的一些:

隶书:LiSu

幼圆:YouYuan

华文细黑:STXihei

华文楷体:STKaiti

华文宋体:STSong

华文中宋:STZhongsong

华文仿宋:STFangsong

方正舒体:FZShuTi

方正姚体:FZYaoti

华文彩云:STCaiyun

华文琥珀:STHupo

华文隶书:STLiti

华文行楷:STXingkai

华文新魏:STXinwei

补充:

使用楷体_GB2312、仿宋_GB2312后,在 Windows 7/Vista/2008 中可能不再显示为对应的字体。

这是因为 Windows 7/Vista/2008 中有楷体、仿宋,默认情况下没有楷体_GB2312、仿宋_GB2312,字体名称相差“_GB2312”。

Copyright © 2012 chyhome All rights reserved.
This site is using the Desk Mess Mirrored theme, v2.0, from BuyNowShop.com.