gpt4 book ai didi

php - Zend 框架上的 CSS

转载 作者:行者123 更新时间:2023-11-28 07:13:02 25 4
gpt4 key购买 nike

我正在使用 Zend Framework 创建网站。我有页眉、页脚和常用页面。我正在使用 public/css/styles.css 的 CSS 文件

尽管没有集成 CSS,但在运行时显示如下:页脚.phtml page

布局.phtml page-main

页脚 phtml 示例

<!-- application/views/scripts/footer.phtml-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<?php echo $this->headLink()->appendStylesheet($this->baseUrl().'css/styles.css') ?>

<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

<?php echo $this->headScript()->appendFile('js/scripts.js') ?>
</head>

<body>
<div id="foot-container">
(...)
</div>
</body>
</html>

布局.phtml

<!-- application/layouts/scripts/layout.phtml -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Frontend Test</title>
<?php echo $this->headLink()->appendStylesheet('css/styles.css') ?>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

<?php echo $this->headScript()->appendFile('js/scripts.js') ?>
<?php echo $this->headLink(); ?>
<?php echo $this->headScript(); ?>
</head>
<body>
<?php echo $this->render('header.phtml') ?>
<?php echo $this->layout()->content ?>
<?php echo $this->render('footer.phtml') ?>
</body>
</html>

最佳答案

在 zendframework 中包含一个 css/js 文件

1.在你的布局文件/head部分

<head>
<?php echo $this->headLink() ; ?>
<?php echo $this->headScript() ; ?>
</head>

2.在你各自的phtml文件中

<?php $this->headLink()->appendStylesheet($this->baseUrl . '/css/yourcss.css'); ?>
<?php $this->headScript()->appendFile($this->baseUrl . '/js/yourjs.js'); ?>

关于php - Zend 框架上的 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32513565/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com