phalcon: 资源文件管 理 引入css,js

<?php

class IndexController extends Phalcon\Mvc\Controller
{
    public function index()
    {

        //添加本地css资源
        $this->assets
            ->addCss('css/style.css')
            ->addCss('css/index.css');

        //添加本地js资源
        $this->assets
            ->addJs('js/jquery.js')
            ->addJs('js/bootstrap.min.js');

    }
}

  

 

 

phtml:

<html>

    
<head>

        
<title>
Some amazing website
</title>

        <?php $this->assets->outputCss() ?>
    
</head>

    
<body>


        <!-- ... -->

        <?php $this->assets->outputJs() ?>
    
</body>

<html>

  

 

方法二:远程文件

<?php

public function indexAction()
{

    //添加远程及本地资源
    $this->assets
        ->addCss('//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css', true )
        ->addCss('css/style.css', false );
}

  

phtml:

同上

 

 

方法三:

<?php

//html头部的js资源
$this->assets
    ->collection('header')
    ->addJs('js/jquery.js')
    ->addJs('js/bootstrap.min.js');

//html尾部的js资源
$this->assets
    ->collection('footer')
    ->addJs('js/jquery.js')
    ->addJs('js/bootstrap.min.js');

  

 

phtml:

<html>

    
<head>

        
<title>
Some amazing website
</title>

        <?php $this->assets->outputJs('header') ?>
    
</head>

    
<body>


        <!-- ... -->

        <?php $this->assets->outputJs('footer') ?>
    
</body>

<html>

  

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值