ragezbla/zfc-twitter-bootstrap

此包最新版本(0.6.0)没有可用的许可证信息。

一个辅助实现 ZF2/3 中 Twitter Bootstrap 的模块

0.6.0 2019-04-17 09:02 UTC

This package is auto-updated.

Last update: 2024-09-17 22:19:32 UTC


README

版本 0.2.1 由 Mike Willbanks 创建

命名

该模块目前命名为 ZfcTwitterBootstrap,因为目标是最终将其纳入 ZF-Commons 区域。一旦这个模块的功能更完整,它将被提交给 ZF-Commons 投票。如果模块未能通过,它将被重命名。

介绍

ZfcTwitterBootstrap 是一个模块,旨在处理 Zend Framework 2 的 Twitter Bootstrap 集成。默认情况下,它包括用于渲染表单、警告、徽章和标签的视图辅助工具。总体而言,此模块将继续扩展视图辅助工具,以生成 Twitter Bootstrap 中的许多项。

需求

安装

您的 composer.json 应包含以下内容

{
    "require": {
        "mwillbanks/zfc-twitter-bootstrap": "@dev"
    }
}

在您的 application.config.php 文件中启用模块

<?php
return array(
    'modules' => array(
        // ...
        'ZfcTwitterBootstrap',
    ),
    // ...
);

功能

  • 表单集成
    • 表单渲染器
    • 表单元素
    • 表单描述
  • 导航集成
    • 面包屑
    • 菜单
  • 视图辅助工具
    • 警告
    • 徽章
    • 关闭图标
    • Flash 消息
    • 图标
    • 图片
    • 标签

路线图

  • Zend\Form - 完成了基本集成
  • 警告消息 - 完成了基本视图辅助工具
  • 关闭图标 - 完成了基本视图辅助工具
  • 徽章 - 完成了基本视图辅助工具
  • Flash 消息 - 完成了基本视图辅助工具
  • 图标 - 完成了基本视图辅助工具
  • 图片 - 完成了基本视图辅助工具
  • 标签 - 完成了基本视图辅助工具
  • 井 - 完成了基本视图辅助工具
  • Zend\Navigation - 完成了基本集成

表单使用

<?php
// render a whole form
echo $this->ztbForm($this->form);
?>


<?php
// render element by element
$form = $this->form;
$form->prepare();
echo $this->form()->openTag($form);
echo $this->ztbFormElement($this->form->get('element'));
echo $this->form()->closeTag();
?>

警告使用

<?php
echo $this->ztbAlert('This is an alert');
// additional parameters: block level and class
echo $this->ztbAlert('This is an alert', true, 'warning');

// explicit usage
// explicit types: info, error, success, warning
echo $this->ztbAlert()->warning('This is an alert');
// explicit additional parameters: block level
echo $this->ztbAlert()->warning('This is an alert');
?>

徽章使用

<?php
echo $this->ztbBadge('This is a badge');
// additional parameters: class
echo $this->ztbBadge('This is a badge', 'info');

// explicit usage
// explicit types: info, important, inverse, success, warning
echo $this->ztbBadge()->info('This is a badge');
?>

关闭图标使用

<?php
echo $this->ztbCloseIcon();
// or render an anchor
echo $this->ztbCloseIcon('a');
?>

FlashMessenger 使用

<?php
// controller/action
// other types Info, Success, Error
$this->flashMessenger()->addMessage(
    'User could not be saved due to a database error.'
);

// other options
$this->flashMessenger()->addMessage(array(
    'message'  => 'User could not be saved due to a database error.',
    'title'    => 'Fatal Error!',
    'titleTag' => 'h4',
    'isBlock'  => true,
);
?>

<?php
// view script
// render all messages in all namespaces
echo $this->ztbFlashMessenger()->render();

// explicit usage
// explicit types: default, info, success, error
echo $this->ztbFlashMessenger('error');
// or
echo $this->ztbFlashMessenger()->render('info');
?>

图标使用

<?php
echo $this->ztbIcon('user');
// additional parameters: color
echo $this->ztbIcon('user', 'white');

// explicit usage
echo $this->ztbIcon()->user();
echo $this->ztbIcon()->user('white');
// icon names with dashes should be camel cased when using this method
echo $this->ztbIcon()->plusSign();
?>

查看 Twitter Bootstrap 图标 了解可用的图标

图片使用

<?php
echo $this->ztbImage('/path/to/img/img.png', 'circle');

// explicit usage
// explicit types: circle, rounded, polaroid
echo $this->ztbImage()->polaroid('/path/to/img/img.png');
?>

标签使用

<?php
echo $this->ztbLabel('This is a label');
// additional parameters: class
echo $this->ztbLabel('This is a label', 'info');

// explicit usage
// explicit types: info, important, inverse, success, warning
echo $this->ztbLabel()->info('This is a label');
?>

导航使用

<?php
echo $this->ztbnavigation()->ztbmenu($navContainer);
echo $this->ztbnavigation()->ztbbreadcrumbs($navContainer);

井使用

<?php
echo $this->ztbWell('This is a well');
// additional parameters: class
echo $this->ztbWell('This is a large well', 'well-large');

// explicit usage
// explicit types: small, large
echo $this->ztbWell()->small('This is a small well');
?>