Zikula_Template_Plugins
[ class tree: Zikula_Template_Plugins ] [ index: Zikula_Template_Plugins ] [ all elements ]

Source for file block.pnformvolatile.php

Documentation is available at block.pnformvolatile.php

  1. <?php
  2. /**
  3.  * Volatile block container
  4.  *
  5.  * @copyright (c) 2006, Zikula Development Team
  6.  * @link http://www.zikula.org
  7.  * @version $Id: block.pnformvolatile.php 24342 2008-06-06 12:03:14Z markwest $
  8.  * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
  9.  * @author Jorn Wildt
  10.  * @package Zikula_Template_Plugins
  11.  * @subpackage Blocks
  12.  */
  13.  
  14. /**
  15.  * Volatile block container
  16.  *
  17.  * This block is a hack, a not so elegant solution, to situations where you need to put
  18.  * pnForms plugins inside conditional smarty tags like if-then-else and foreach. You can
  19.  * get into problems if you make templates like this:
  20.  * <code>
  21.  *  <!--[foreach from=... item=...]-->
  22.  *    <!--[pnformtextinput ...]-->
  23.  *    <!--[pnformbutton ...]-->
  24.  *  <!--[/foreach]-->
  25.  * </code>
  26.  * This is because the number of plugins on the page may change from one page to another
  27.  * due to changing conditions or amount of items in the foreach loop: on the first page
  28.  * you might have 5 iterations, whereas on postback you suddenly have 6. What should then
  29.  * be done to the missing (or excess) persisted plugin data on postback? The answer is:
  30.  * pnForms cannot handle this - your code will break!
  31.  *
  32.  * So you need to tell pnForms that the block inside the foreach tags is volatile - pnForms
  33.  * should not try to save the state of the plugins inside the foreach loop. This is done
  34.  * with the volatile block:
  35.  * <code>
  36.  *  <!--[pnformvolatile]-->
  37.  *  <!--[foreach from=... item=...]-->
  38.  *    <!--[pnformtextinput ...]-->
  39.  *    <!--[pnformbutton ...]-->
  40.  *  <!--[/foreach]-->
  41.  *  <!--[/pnformvolatile]-->
  42.  * </code>
  43.  * This disables the ability to persist data in the pnForms plugins, but does save you
  44.  * from trouble in some situations.
  45.  *
  46.  * You don't need the volatile block if you can guarantee that the number of elements will
  47.  * be the same always.
  48.  *
  49.  * @package pnForm
  50.  * @subpackage Plugins
  51.  */
  52. class pnFormVolatile extends pnFormPlugin
  53. {
  54.     var $volatile = 1;
  55.  
  56.     function getFilename()
  57.     {
  58.         return __FILE__// FIXME: may be found in smarty's data???
  59.     }
  60.  
  61.  
  62.     function create(&$render&$params)
  63.     {
  64.     }
  65. }
  66.  
  67.  
  68. function smarty_block_pnformvolatile($params$content&$render)
  69. {
  70.     return $render->pnFormRegisterBlock('pnFormVolatile'$params$content);
  71. }

Documentation generated on Fri, 18 Jul 2008 21:43:12 +0200 by phpDocumentor 1.4.1