我现在从Zend Framework 2开始,所以我还在学习如何使用它。我试图构建一个类似于下面的layout.phtml页面:
<?php echo $this->doctype(); ?>
<html lang="pt-BR">
<head>
<meta charset="utf-8">
<!-- Title Head -->
<?php
$NAME_APPLICATION = 'Enquete';
var_dump($this);
echo $this
->headTitle($NAME_APPLICATION)
->setSeparator(' - ')
->setAutoEscape(false)
;
?>
<!-- Meta Head -->
<?php
echo $this
->headMeta()
->appendName('viewport', 'width=device-width, initial-scale=1.0')
->appendHttpEquiv('X-UA-Compatible', 'IE=edge')
;
?>
<!-- Styles -->
<?php
echo $this
->headLink(array('rel' => 'shortcut icon', 'type' => 'image/vnd.microsoft.icon', 'href' => $this->basePath() . '/img/favicon.ico'))
->prependStylesheet($this->basePath() . '/css/style.css')
->prependStylesheet($this->basePath() . '/css/bootstrap-theme.min.css')
->prependStylesheet($this->basePath() . '/css/bootstrap.min.css')
;
?>
</head>
<body>
<div class="container">
<div class="header">
<ul class="nav nav-pills pull-right">
<li class="active"><a href="#">Início</a></li>
<li><a href="#">Sobre</a></li>
</ul>
<h3 class="text-muted"><?php echo $NAME_APPLICATION; ?></h3>
</div>
<div class="row marketing">
<?php echo $this->content; ?>
</div>
<div class="footer">
<p class="muted credit pull-left">Company <a href="">© 2013</a></p>
<p class="muted credit pull-right">Desenvolvido por <a href="http://igorrocha.com.br">Igor Rocha</a>.</p>
</div>
</div>
<!-- Scripts -->
<?php
echo $this
->headScript()
->prependFile($this->basePath() . '/js/bootstrap.min.js')
->prependFile($this->basePath() . '/js/jquery.min.js')
->prependFile($this->basePath() . '/js/respond.min.js', 'text/javascript', array('conditional' => 'lt IE 9',))
->prependFile($this->basePath() . '/js/html5shiv.js', 'text/javascript', array('conditional' => 'lt IE 9',))
;
echo $this->inlineScript();
?>
</body>
</html>
我只有一个名为&#34; Enquete&#34;的模块,但是当我尝试访问:&#34; localhost / myproject / public&#34;这些脚本和样式表都没有呈现,请参阅以下内容:
<div class="topo-table">
<a class="btn btn-success" title="Novo"><span class="glyphicon glyphicon-plus"></span></a>
<div class="btn-group" title="Quantidades por Página">
<button type="button" class="btn btn-default">005</button>
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul class="dropdown-menu pull-right" style="min-width: 75px" role="menu">
<li class="active"><a href="#">005</a></li>
<li><a href="#">010</a></li>
<li><a href="#">025</a></li>
<li><a href="#">050</a></li>
<li><a href="#">100</a></li>
</ul>
</div>
<form class="form-inline pull-right" role="form">
<div class="form-group">
<label class="sr-only" for="localizar">Buscar...</label>
<input type="search" class="form-control" id="localizar" placeholder="Bucar...">
</div>
<button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-search"></span></button>
</form>
</div>
<br />
<div class="corpo-table">
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>#</th>
<th>Nome</th>
<th>Tel. Principal</th>
<th>Tel. Qua.</th>
<th>Data Criação</th>
<th>Ação</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Fortaleza Ceará Brasil</td>
<td>(085)85858585</td>
<td class="text-center">2</td>
<td>
我的module.config.php
<?php
return array(
# definir e gerenciar controllers
'controllers' => array(
'invokables' => array(
'HomeController' => 'Enquete\Controller\HomeController'
),
),
# definir e gerenciar rotas
'router' => array(
'routes' => array(
'home' => array(
'type' => 'Literal',
'options' => array(
'route' => '/',
'defaults' => array(
'controller' => 'HomeController',
'action' => 'index',
),
),
),
),
),
# definir e gerenciar servicos
'service_manager' => array(
'factories' => array(
#'translator' => 'Zend\I18n\Translator\TranslatorServiceFactory',
),
),
# definir e gerenciar layouts, erros, exceptions, doctype base
'view_manager' => array(
'display_not_found_reason' => true,
'display_exceptions' => true,
'doctype' => 'HTML5',
'not_found_template' => 'error/404',
'exception_template' => 'error/index',
'template_map' => array(
'layout/layout' => __DIR__ . '/../view/layout/layout.phtml',
'enquete/home/index' => __DIR__ . '/../view/enquete/home/index.phtml',
'error/404' => __DIR__ . '/../view/error/404.phtml',
'error/index' => __DIR__ . '/../view/error/index.phtml',
),
'template_path_stack' => array(
__DIR__ . '/../view',
),
),
);
答案 0 :(得分:0)
您可以通过两种方法解决此问题:
将所有.css和.js文件放在主公用文件夹(位于模块之外)中,您可以像这样使用:
prependFile($this->basePath() . '/css/abc.css')
您可以分叉this module,然后您可以在模块中创建一个公共文件夹,并将.css / .js文件放入其中。