【发布时间】:2013-06-09 16:17:17
【问题描述】:
我正在使用 Symfony 1.4.20 开发一个网站,但设计师想要这样的图像
每一个都是一个管理模块生成槽任务doctrine:generate-admin。
我如何完成这项任务?我的意思是适用于由选项卡制作的每个界面?
编辑
根据@antony 提出的建议,我这样做:
在/frontend/modules/emisores/actions/components.class.php里面创建一个components.class.php,在类里面添加这段代码:
class emisoresComponents extends sfComponents {
public function executeIndex(sfWebRequest $request) {
$this->sdriving_emisors = Doctrine_Core::getTable('SdrivingEmisor')->createQuery('a')->execute();
}
}
在创建标签的视图中包含组件
<?php include_component('emisores'); ?>
但是我得到了这个错误
sfComponents 初始化失败。
怎么了?
EDIT2 我在分页方面遇到了一些问题,因为我被重定向到模块而不是在选项卡内获取分页。我将组件更改为:
public function executeIndex(sfWebRequest $request) {
$this->pager = new sfDoctrinePager('SdrivingEmisor', 10);
$this->pager->setQuery(Doctrine_Core::getTable('SdrivingEmisor')->createQuery('a'));
$this->pager->setPage($request->getParameter('page', 1));
$this->pager->init();
}
然后在视图(_index.php)中我写了这个:
<?php if (count($pager) > 0): ?>
<table class="table table-condensed table-striped table-bordered table-hover marginBottom">
<thead>
<tr>
<th><?php echo __('Número') ?></th>
<th> </th>
</tr>
</thead>
<tbody>
<?php foreach ($pager->getResults() as $sdriving_emisor): ?>
<tr>
<td><?php echo $sdriving_emisor->getNumero() ?></td>
<td>
<a href="<?php echo url_for('emisores/edit?idemisor=' . $sdriving_emisor->getIdemisor() . '&idempresa=' . $sdriving_emisor->getIdempresa()) ?>" class="btn btn-success btn-mini">Editar</a>
<a href="<?php echo url_for('emisores/delete?idemisor=' . $sdriving_emisor->getIdemisor() . '&idempresa=' . $sdriving_emisor->getIdempresa()) ?>" class="btn btn-danger btn-mini">Eliminar</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php else: ?>
<div class="alert alert-block">
<h4><?php echo __('Información!') ?></h4>
<?php echo __('No se ha creado ningún emisor aún. Haga clic en el botón "Crear Nuevo" para crear uno.') ?>
</div>
<?php endif; ?>
<div class="pagination">
<strong><?php echo count($pager) ?></strong> <?php echo __('emisores encontrados') ?>
<?php if ($pager->haveToPaginate()): ?>
<div class="clearfix"></div>
<ul>
<li><?php echo link_to(__('Anterior'), 'emisores/index?page=' . $pager->getPreviousPage()) ?></li>
<?php $links = $pager->getLinks(); ?>
<?php foreach ($links as $page): ?>
<li>
<?php echo ($page == $pager->getPage()) ? $page : link_to($page, 'emisores/index?page=' . $page); ?>
<?php if ($page != $pager->getCurrentMaxLink()): ?>
<?php endif ?>
</li>
<?php endforeach; ?>
<li><?php echo link_to(__('Siguiente'), 'emisores/index?page=' . $pager->getNextPage()) ?></li>
</ul>
<?php endif; ?>
</div>
但正如我所说,我被重定向到 emisor 模块而不是在活动选项卡内分页,有什么建议吗?
【问题讨论】:
-
看看sfAdminDashPlugin。即使您不需要它的所有功能,它也可以作为编写自己的解决方案的良好起点。
标签: php tabs symfony-1.4