Добро пожаловать на форум PHP программистов!
За последние 24 часа нас посетил 20431 программист и 979 роботов. Сейчас ищут 911 программистов ...

flexy:if="variable or method()"

Вернуться к: HTML_Template_Flexy

flexy:if="variable or method()"

flexy:if="variable or method()" – creates a PHP if conditional tag

Synopsis

Usage ( flexy:if="variable" , flexy:if="method()" , flexy:if="object.method()" )

creates an if condition surrounding the tag that it's included in.

Parameter

  • string variable - relates to $object->variable

  • string method - relates to $object->method()

  • string object.method relates to $object->object->method()

Example

Setting variables for foreach

          class output {     function hasTest() {         return false;     }          function run() {         $this->a = true;         $this->message = 'oops'         $template->outputObject($this);     } }

flexy:if in template

     <a href="{baseURL}/somepath.html" flexy:if="a">this is the a link</a> <a href="{baseURL}/somepath.html" flexy:if="!a">this is not the a link</a> <b flexy:if="hasTest()">hasTest is true</b> <b flexy:if="!hasTest()">hasTest is false</b>  <span flexy:if="message" class="error">{message}</span>

Compiled template

                    <?php if ($t->a)  { ?><A HREF="<?php echo htmlspecialchars($t->baseURL); ?>/somepath.html">this is the a link</A><?php } ?> <?php if (!$t->a)  { ?><A HREF="<?php echo htmlspecialchars($t->baseURL); ?>/somepath.html">this is not the a link</A><?php } ?> <?php if (isset($t) && method_exists($t,'hasTest')) if ($t->hasTest()) {  ?><B>hasTest is true</B><?php } ?> <?php if (isset($t) && method_exists($t,'hasTest')) if (!$t->hasTest()) {  ?><B>hasTest is false</B><?php } ?>   <?php if ($t->message)  { ?><SPAN CLASS="error"><?php echo htmlspecialchars($t->message); ?></SPAN><?php } ?>

Simple ouput example

                 this is the a link hasTest is false  oops


Вернуться к: HTML_Template_Flexy

© 2024 «PHP.RU — Сообщество PHP-Программистов»
Главная | Форум | Реклама на сайте | Контакты VIP Сувениры
Разработка компании ODware