Loading ...
Sorry, an error occurred while loading the content.

751Re: {include file assign} / {input...} issues

Expand Messages
  • Shekar C. Reddy
    Aug 4 8:16 AM
    • 0 Attachment
      Manuel,

      Would you be able to help me with this issue?

      Thanks much in advance...




      --- In forms-dev@yahoogroups.com, "Shekar C. Reddy" <zendfw@...>
      wrote:
      >
      > Manuel,
      >
      > Regret for the delay in replying as I was moved to another project.
      I've pasted the
      > compiled output of the toolbar.tpl:
      >
      > <?php /* Smarty version 2.6.11, created on 2006-06-08 02:55:10
      > compiled from toolbar.tpl */ ?>
      > <?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
      > smarty_core_load_plugins(array('plugins' => array(array
      ('modifier', 'default', 'toolbar.tpl', 8,
      > false),array('function', 'formaddinputpart', 'toolbar.tpl', 63,
      false),array('function',
      > 'formadddatapart', 'toolbar.tpl', 118, false),)), $this); ?>
      > <?php ob_start(); ?>
      >
      > <?php if ($this->_tpl_vars['type'] == 'form'): ?>
      >
      > <?php $_from = $this->_tpl_vars['toolbar']; if (!is_array($_from)
      && !is_object($_from))
      > { settype($_from, 'array'); }if (count($_from)):
      > foreach ($_from as $this->_tpl_vars['name'] => $this->_tpl_vars
      ['toolbar']):
      > ?>
      > <?php $this->_smarty_vars['capture']['formdata'] =
      ob_get_contents(); ob_end_clean
      > (); echo smarty_insert_formaddinputpart(array('input' => ($this-
      >_tpl_vars['name']),'data'
      > => $this->_smarty_vars['capture']['formdata']), $this); ob_start
      (); ?>
      > <?php endforeach; unset($_from); ?>
      >
      > <?php endif; ?>
      >
      >
      >
      > Please note I have been using the code precisely as included in
      your example files using
      > Smarty successfully without any issues except or the {if} tag that
      did not work as expected.
      > So far, so good! But when I added the 'if' to the prefilter as
      suggested by you, it is not
      > skipping the line of code that has the conditional and running into
      errors if the type is not
      > 'fom' as in the above code.
      >
      > Further, when I place some text between a {if} tag, the text is
      rendered at the 'top-most' of
      > the page - outside every other table - as the first line in the
      output instead of displaying
      > at the current position in the template.
      >
      > On another note, I've noticed that the page that used to take 1.2
      secs to render earlier is
      > taking 2.0 secs with the if prefilter added (caching turned off).
      >
      > You could try this if prefilter yourself and please let me know.
      >
      > Thanks and regards,
      >
      >
      >
      >
      > --- In forms-dev@yahoogroups.com, "Shekar C. Reddy" <zendfw@> wrote:
      > >
      > > Manuel,
      > >
      > > Regret for the delay in responding. I tried to generate the
      compiled
      > > template file but for some reason, it is not generating the
      compiled
      > > file (maybe, loading from the memory itself) although I set
      > > compile_check and force_compile to true.
      > >
      > > Further, using the new prefilter that address the {if} tag, some
      of
      > > the text within these tags is appearing at the TOP of the page
      > > instead of a particular position.
      > >
      > > Here is the code:
      > >
      > > PREFILTER
      > > ---------
      > > $search = array(
      > > '/{input\s+name=("[^"]+"|\'[^\']+\'|\S+)}/i',
      > > '/{hiddeninput\s+name=("[^"]+"|\'[^\']+\'|\S+)}/i',
      > > '/{label\s+for=("[^"]+"|\'[^\']+\'|\S+)}/i',
      > > '/({include[^}]*})/i',
      > > '/({\\/?if[^}]*})/i'
      > > );
      > > $replace = array(
      > > '{/capture}{formaddinputpart input=\\1
      data=$smarty.capture.formdata}
      > > {capture name="formdata"}',
      > > '{/capture}{formaddinputhiddenpart input=\\1
      > > data=$smarty.capture.formdata}{capture name="formdata"}',
      > > '{/capture}{formaddlabelpart for=\\1
      data=$smarty.capture.formdata}
      > > {capture name="formdata"}',
      > > '{/capture}{formadddatapart data=$smarty.capture.formdata}\\1
      > > {capture name="formdata"}',
      > > '{/capture}{formadddatapart data=$smarty.capture.formdata}\\1
      > > {capture name="formdata"}'
      > > );
      > >
      > >
      > > TEMPLATE
      > > --------
      > > {$header}
      > > {$content}
      > > {$message}
      > > <table>
      > > <tr>
      > > <td>
      > > {if $tools}
      > > {foreach key=name item=toolbar from=$toolbar}
      > > {input name="$name"}
      > > {/foreach}
      > > {/if}
      > > </td>
      > > </tr>
      > > </table>
      > > {$footer}
      > >
      > >
      > > Template vars assigned to Smarty
      > > --------------------------------
      > > $smarty->assign('tools', 0);
      > > $smarty->assign('toolbar', array
      ('save'=>'Save','cancel'=>'Cancel'));
      > > $smarty->display('test-if.tpl');
      > >
      > > Elements within the $toolbar are added as inputs if $tools is set
      to
      > > true; otherwise, the page does not use form_class, at all (so no
      > > inputs added in that case). I'm trying to get the {if} tag to skip
      > > the {input} tags in the template if $tools is false. The idea is
      to
      > > isolate the logic to toolbar.tpl that can be included in any
      > > template without errors but the prefilter is not processing the
      {if}
      > > tags properly. However, here are two previously compiled files
      that
      > > have their $tools var set to true (if that helps):
      > >
      > > <?php echo $this->_tpl_vars['header']; ?>
      > > <?php echo $this->_tpl_vars['content']; ?>
      > > <table>
      > > <tr>
      > > <td>
      > > <?php $_smarty_tpl_vars = $this->_tpl_vars;
      > > $this->_smarty_include(array('smarty_include_tpl_file'
      > > => 'toolbar.tpl', 'smarty_include_vars' => array('position'
      > > => 'top')));
      > > $this->_tpl_vars = $_smarty_tpl_vars;
      > > unset($_smarty_tpl_vars);
      > > ?>
      > > <?php echo $this->_tpl_vars['message']; ?>
      > >
      > > </td>
      > > </tr>
      > > </table>
      > > ........................................
      > > <?php if ($this->_tpl_vars['tools']): ?>
      > > <?php ob_start();
      > > $_smarty_tpl_vars = $this->_tpl_vars;
      > > $this->_smarty_include(array('smarty_include_tpl_file'
      > > => 'toolbar.tpl', 'smarty_include_vars' => array()));
      > > $this->_tpl_vars = $_smarty_tpl_vars;
      > > unset($_smarty_tpl_vars);
      > > $this->assign('toolbar', ob_get_contents());
      > > ob_end_clean();
      > > endif;
      > >
      > >
      > > OUTPUT
      > > ------
      > > <pre>
      > > <b>Error</b>: 256 <br />
      > > <b>Text </b>: Smarty error: [in test-if.tpl line 7]: syntax error:
      > > unrecognized tag 'formadddatapart' (Smarty_Compiler.class.php,
      line
      > > 580) <br />
      > > <b>File </b>: c:\web\library\smarty\Smarty.class.php <br />
      > > <b>Line </b>: 1095 <br />
      > > <b>Date </b>: May 29, 2006, 9:47 am <br />
      > > <br />
      > > <br />
      > > <b>Backtrace</b>:<br />
      > > <table border=1 cellspacing=0 cellpadding=2 bgcolor=eeeeee
      width=99%
      > > ><tr>
      > > <td><font face="Verdana, Tahoma"
      > > size="2">Class</font></td>
      > > <td><font face="Verdana, Tahoma"
      > > size="2">Function</font></td>
      > > <td><font face="Verdana, Tahoma"
      > > size="2">Line</font></td>
      > > <td><font face="Verdana, Tahoma"
      > > size="2">File</font></td><tr><td><font face="Verdana, Tahoma"
      > > size="1"></font>
      > > </td><td><font face="Verdana,
      > > Tahoma" size="1">trigger_error("Smarty error: [in test-if.tpl line
      > > 7]: syntax error: unrecognized tag 'formadddatapart'
      > > (Smarty_Compiler.class.php, line 580)", "256")</font>
      > > </td><td><font face="Verdana,
      > > Tahoma" size="1">1095</font>
      > > </td><td><font face="Verdana,
      > > Tahoma"
      > >
      size="1">c:\web\library\smarty\Smarty.class.php</font></td></tr><tr><
      > > td><font face="Verdana, Tahoma" size="1">Smarty</font>
      > > </td><td><font face="Verdana,
      > > Tahoma" size="1">trigger_error("[in test-if.tpl line 7]: syntax
      > > error: unrecognized tag 'formadddatapart'
      > > (Smarty_Compiler.class.php, line 580)", "256")</font>
      > > </td><td><font face="Verdana,
      > > Tahoma" size="1">1814</font>
      > > </td><td><font face="Verdana,
      > > Tahoma"
      > >
      size="1">c:\web\library\smarty\Smarty.class.php</font></td></tr><tr><
      > > td><font face="Verdana, Tahoma" size="1">Smarty</font>
      > > </td><td><font face="Verdana,
      > > Tahoma" size="1">_trigger_fatal_error("syntax error: unrecognized
      > > tag 'formadddatapart'", "test-
      > >
      if.tpl", "7", "c:\web\library\smarty\Smarty_Compiler.class.php", "580
      > > ", "256")</font>
      > > </td><td><font face="Verdana,
      > > Tahoma" size="1">2202</font>
      > > </td><td><font face="Verdana,
      > > Tahoma"
      > >
      size="1">c:\web\library\smarty\Smarty_Compiler.class.php</font></td><
      > > /tr><tr><td><font face="Verdana, Tahoma"
      > > size="1">Smarty_Compiler</font>
      > > </td><td><font face="Verdana,
      > > Tahoma" size="1">_syntax_error("unrecognized
      > >
      tag 'formadddatapart'", "256", "c:\web\library\smarty\Smarty_Compiler
      > > .class.php", "580")</font>
      > > </td><td><font face="Verdana,
      > > Tahoma" size="1">580</font>
      > > </td><td><font face="Verdana,
      > > Tahoma"
      > >
      size="1">c:\web\library\smarty\Smarty_Compiler.class.php</font></td><
      > > /tr><tr><td><font face="Verdana, Tahoma"
      > > size="1">Smarty_Compiler</font>
      > > </td><td><font face="Verdana,
      > > Tahoma" size="1">_compile_tag("formadddatapart
      > > data=$smarty.capture.formdata")</font>
      > > </td><td><font face="Verdana,
      > > Tahoma" size="1">312</font>
      > > </td><td><font face="Verdana,
      > > Tahoma"
      > >
      size="1">c:\web\library\smarty\Smarty_Compiler.class.php</font></td><
      > > /tr><tr><td><font face="Verdana, Tahoma"
      > > size="1">Smarty_Compiler</font>
      > > </td><td><font face="Verdana,
      > > Tahoma" size="1">_compile_file("test-if.tpl", "{$header}
      > > {$content}
      > > {$message}
      > > <table>
      > > <tr>
      > > <td>
      > > {if $tools}
      > > {foreach key=name item=toolbar
      > > from=$toolbar}
      > > {input
      > > name="$name"}
      > > {/foreach}
      > > {/if}
      > > </td>
      > > </tr>
      > > <tr>
      > > </table>", null)</font>
      > > </td><td><font face="Verdana,
      > > Tahoma" size="1">1491</font>
      > > </td><td><font face="Verdana,
      > > Tahoma"
      > >
      size="1">c:\web\library\smarty\Smarty.class.php</font></td></tr><tr><
      > > td><font face="Verdana, Tahoma" size="1">Smarty</font>
      > > </td><td><font face="Verdana,
      > > Tahoma" size="1">_compile_source("test-if.tpl", "{$header}
      > > {$content}
      > > {$message}
      > > <table>
      > > <tr>
      > > <td>
      > > {if $tools}
      > > {foreach key=name item=toolbar
      > > from=$toolbar}
      > > {input
      > > name="$name"}
      > > {/foreach}
      > > {/if}
      > > </td>
      > > </tr>
      > > <tr>
      > > </table>", null, "C:/Documents and Settings/Shawn/My
      > > Documents/web/dev\temp\compile\%%CC^CC1^CC14DFC8%%test-
      if.tpl.inc")
      > > </font>
      > > </td><td><font face="Verdana,
      > > Tahoma" size="1">1424</font>
      > > </td><td><font face="Verdana,
      > > Tahoma"
      > >
      size="1">c:\web\library\smarty\Smarty.class.php</font></td></tr><tr><
      > > td><font face="Verdana, Tahoma" size="1">Smarty</font>
      > > </td><td><font face="Verdana,
      > > Tahoma" size="1">_compile_resource("test-if.tpl", "C:/Documents
      and
      > > Settings/Shawn/My Documents/web/dev\temp\compile\%%
      CC^CC1^CC14DFC8%%
      > > test-if.tpl.php")</font>
      > > </td><td><font face="Verdana,
      > > Tahoma" size="1">1256</font>
      > > </td><td><font face="Verdana,
      > > Tahoma"
      > >
      size="1">c:\web\library\smarty\Smarty.class.php</font></td></tr><tr><
      > > td><font face="Verdana, Tahoma" size="1">Smarty</font>
      > > </td><td><font face="Verdana,
      > > Tahoma" size="1">fetch("test-if.tpl", null, null, true)</font>
      > > </td><td><font face="Verdana,
      > > Tahoma" size="1">1108</font>
      > > </td><td><font face="Verdana,
      > > Tahoma"
      > >
      size="1">c:\web\library\smarty\Smarty.class.php</font></td></tr><tr><
      > > td><font face="Verdana, Tahoma" size="1">Smarty</font>
      > > </td><td><font face="Verdana,
      > > Tahoma" size="1">display("test-if.tpl")</font>
      > > </td><td><font face="Verdana,
      > > Tahoma" size="1">244</font>
      > > </td><td><font face="Verdana,
      > > Tahoma"
      > >
      size="1">c:\web\dev\www\index.html</font></td></tr></tr></table><br /
      > > >
      > > <br />
      > > </pre><pre><b><u><font
      > > color='red'>CONTEXT</font></u></b></pre><pre>Array
      > > (
      > > [error_msg] => [in test-if.tpl line 7]: syntax error:
      > > unrecognized tag 'formadddatapart' (Smarty_Compiler.class.php,
      line
      > > 580)
      > > [error_type] => 256
      > > )
      > > </pre><br />
      > >
      > >
      > >
      > >
      > > --- In forms-dev@yahoogroups.com, Manuel Lemos <mlemos@> wrote:
      > > >
      > > > Hello,
      > > >
      > > > on 05/04/2006 11:19 AM Shekar C. Reddy said the following:
      > > > > Manuel,
      > > > >
      > > > > Yes, I appended those strings as elements at the end of each
      > > array
      > > > > (search/replace) while keeping the old ones. But it did not
      > > work.
      > > > > Could be a logic error and maybe we are 'this' close to
      > > squashing
      > > > > it. Unfortunately, I'm weak with regex.
      > > >
      > > > I do not see why it does not work. Can you get the compiled
      > > template
      > > > file that Smarty generates so I can see what may not be working?
      > > >
      > > > --
      > > >
      > > > Regards,
      > > > Manuel Lemos
      > > >
      > > > Metastorage - Data object relational mapping layer generator
      > > > http://www.metastorage.net/
      > > >
      > > > PHP Classes - Free ready to use OOP components written in PHP
      > > > http://www.phpclasses.org/
      > > >
      > >
      >
    • Show all 22 messages in this topic