Other template examples

  • Views Views: 10,225
  • Last updated Last updated:
  • Showing error messages in-line​

    Clone your template and edit your default_element.php to look like this:

    PHP:
    <?php
    /**
    * Default Form:Group Template - show error messages inline
    *
    * @package Joomla
    * @subpackage Fabrik
    * @copyright Copyright (C) 2005 FabrikAll rights reserved.
    * @license [URL]http://www.gnu.org/copyleft/gpl.html[/URL] GNU/GPL, see LICENSE.php
    * @since 3.0
    **/

    /*
    This part of the template is what actually renders each individual element. You will be loading this
    template multiple times (once for each element you want to display) from your default_group.php file.

    You probably won't need to edit this file - most changes you want can probably be done
    by overriding the template_css.php file in your J template html overrides folder

    If you do edit this file, make sure you use the same parts of the element this example uses,
    i.e. the same class definitions, etc.
    */
    ?>

    <?php if ($this->tipLocation == 'above') {
    echo '<div>' . $element->tipAbove . '</div>';
    }?>

    <?php
    // As this is a custom template, you may want to exclude $this->element->column
    // which is the inline css required to abide by the group's column setup
    ?>

    <div <?php echo @$this->element->column;?> class="<?php echo $this->element->containerClass;?>">
    <div class="fabrikElement">
    <?php echo $this->element->element;?>
    <?php if ($this->element->error != "") :?>
    <?php echo $this->element->error;?>
    <?php endif;?>
    </div>
    <?php if ($this->tipLocation == 'side') {
    echo $element->tipSide;
    }?>
    <div style="clear:both"></div>
    </div>

    <?php if ($this->tipLocation == 'below') {
    echo '<div>' . $element->tipBelow . '</div>';
    }?>

    <?php
    $this->element->rendered = true;
    ?>

    Showing an element only if it has a value​


    Say we want to hide the element 'countries___id', when it has no value. Clone your form/details template, and the edit its default_group.php file:
    PHP:

    <?php

    // No direct access
    defined('_JEXEC') or die('Restricted access');

    foreach ($this->Elements as $element) :
    if ($element->id === 'countries___id' && $element->value == '') :
    continue;
    endif;
    // Render the rest of your group template as usual......
    <?php endforeach;?>
    [php]
Back
Top