项目作者: arnaud-zg

项目描述 :
Zend Framework 2 (ZF2) Simple modal module
高级语言: PHP
项目地址: git://github.com/arnaud-zg/zf2-module-modal.git
创建时间: 2019-10-01T08:23:31Z
项目社区:https://github.com/arnaud-zg/zf2-module-modal

开源协议:

下载


zf2-module-modal

ZF2 Simple module modal

Created for Testapic

Introduction

This module is a Zend Framework 2 module to generate some simple and custom modals.

Alt text

Configuration

  1. ZF2 Version 2.3.4
  2. Semantic UI 1.8.1

Installation

You have to put Semantic UI at “/public/css/“ and don’t forget to set your css framwork link.

If you want to include a css framwork
$headlink->prependStylesheet('/css/dist/semantic.min.css');

Usage

  1. Controller
    The modal variable contains the data to generate modal view.

Override Mode
Mandatory : confirmAction

  1. $modal = array(
  2. "id" => "Something",
  3. 'url_redir' => $this->getRequest()->getUri()->getPath(),
  4. 'url_confirm' => 'PATH_OF_CONFIRM_VIEW',
  5. 'title' => "Title",
  6. 'flash' => array("Sentence 1"),
  7. 'content' => "Display something",
  8. 'btn' => array("confirm" => "Ok", "noconfirm" => "Fermer"),
  9. );

Custom Mode
Mandatory : infoAction, confirmAction

  1. $modal = array(
  2. "id" => "Something",
  3. 'url_redir' => $this->getRequest()->getUri()->getPath(),
  4. 'url_info' => 'PATH_OF_INFO_VIEW',
  5. 'url_confirm' => 'PATH_OF_CONFIRM_VIEW',
  6. );

View

  1. <a href="#" class="smodal" data-modal='<?= $this->modallink(array("id" => 1), $this->modal) ?>'>
  2. Display modal
  3. </a>
  1. infoAction
    If ‘url_info’ isn’t set, ‘/ui/modal/info’ will be called by defaut.
  • Generate a modal

    1. public function infoAction() {
    2. $modal = new ModalController($this, 'PATH_OF_INFO_VIEW');
    3. $data = array(); // Data ready to be used in infoAction variable named $page
    4. $modal->setTitle("Title");
    5. $modal->setData($data);
    6. $modal->setButton($modal->data->btn);
    7. return $modal->render();
    8. }
  • View of action infoAction (info.phtml)

    1. <?php
    2. $page = (object) $this->layout()->child_page;
    3. ?>
    4. <?= $this->translate("Souhaîtez-vous vraiment effectuer cette action sur l'élement ?"); ?>
  1. confirmAction
    If ‘url_confirm’ isn’t set, ‘/ui/modal/confirm’ will be called by default.
  • Generate a modal

    1. public function confirmAction() {
    2. $modal = new ModalController($this, 'PATH_OF_CONFIRM_VIEW');
    3. $modal->setFlashMessenger("L'action a bien été éffectuée");
    4. // Add some queries
    5. $modal->setTitle("Title");
    6. return $modal->render();
    7. }
  • View of action infoAction (info.phtml)

    1. <?php
    2. $page = (object) $this->layout()->child_page;
    3. ?>
    4. <div class="ui grid">
    5. <div class="column">
    6. <div class="ui red large message">
    7. <?php echo $this->translate($page->string); ?>
    8. </div>
    9. </div>
    10. </div>