1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice

[Solved]: List Div Custom Template & Ajax Navigation

Discussion in 'Community' started by sunnyjey, May 24, 2019.

  1. sunnyjey

    sunnyjey Active Member

    Level: Community
    I have created custom Div List template to output required field like:

    My default_row.php :

    Code (Text):

    // No direct access
    defined('_JEXEC') or die('Restricted access');
    $rowClass = isset($this->_row->rowClass) ? $this->_row->rowClass : '';

    $myelement = $this->_row->data->mytable___myelement_name;

    ?>
        <div ="row-fluid">
                 <?php echo $myelement;?>
    </div>
       
    When I select Ajaxify List : NO. It echoes correct Element_Name.

    For eg:
    RowID 1: Name1
    RowID2: Name2
    RowID3: Name3
    .....

    BUT, When I activate Ajaxify Navigation to YES, it echoes Element_Name of First Row in all Pages and rows.

    For eg:
    RowID 1: Name1
    RowID2: Name1
    RowID3: Name1
    .....

    I have gone through multiple threads in forum for last 3 hours but didn't find the solution.

    NB: Latest J! and Latest F! (updated 2 days ago). The default DIV template works well on Ajax Navigation.
     
    Last edited: May 24, 2019
  2. troester

    troester Well-Known Member Staff Member

    Level: Community
    For the ajax update you must keep the structure with HTML ids and classes.

    So default.php has a <div ... id="list_3_com_fabrik_3_row_77.... (created by bootstrapGrid)

    Usually default_row.php includes a loop on your elements especially including the id element.
     
  3. sunnyjey

    sunnyjey Active Member

    Level: Community
    I'm sorry, but I cannot figure out as it is beyond my comprehension.

    What changes are required in default.php and default_row.php of DIV template.

    Can you please give me example .
     
  4. troester

    troester Well-Known Member Staff Member

    Level: Community
    You say "the default div works well", so use this as example and change as less as possible to meet your needs.
    Did you modify default.php?
    Is your id element published?
     
  5. sunnyjey

    sunnyjey Active Member

    Level: Community
    Yes, DIV works flawlessly. Even the custom non-ajax LIST template works. I have to add additional static text prefix to the Element, for e.g This item name is <?php echo $myelement;?> So it is not possible, unless I do some changes in default_row.php

    No. Do I need to modify it ?

    Yes. I have checked with different list and different J! template (Protostar), but same error.
     
  6. sunnyjey

    sunnyjey Active Member

    Level: Community
    Thanks to the @startpoint . The following template is nicely working with on-fly Ajax Navigation of the List. Ref Thread: http://fabrikar.com/forums/index.php?threads/custom-templates.50465/#post-263764

    PHP:
    <?php
    // No direct access
    defined('_JEXEC') or die('Restricted access');

    $rowClass = isset($this->_row->rowClass) ? $this->_row->rowClass : '';
    $user = JFactory::getUser()->groups;
    $userKeys = array_keys($user);
    // the first element of your array is:
    $userGroup = $user[$userKeys[0]];

    $list_data = array();
    foreach ($this->headings as $heading => $label) :
        $elem_data = new stdClass;
        $h = $this->headingClass[$heading];
        $c = $this->cellClass[$heading];
        $hStyle = empty($h['style']) ? '' : 'style="' . $h['style'] . '"';
        $cStyle = empty($c['style']) ? '' : 'style="'. $c['style'].'"';
        $lbl = $label;
        $lbl_class = $h['class'];
        $el_class = $c['class'];
        $el_data = @$this->_row->data->$heading;
        if($heading !== 'fabrik_select' && $heading !== 'fabrik_actions'){
            $el_name = explode ("___", $heading)[1];
            $elem_data->el_name = $el_name;
            $elem_data->el_lbl = $lbl;
            $elem_data->lbl_class = $el_class;
            $elem_data->el_class = $el_class;
            $elem_data->el_data = $el_data;  
            $list_data[$el_name] = $elem_data;
        }
           
        if($heading == 'fabrik_actions'){
            $actions_class = $el_class;
            $actions = $el_data;
            $elem_data->actions_class = $actions_class;
            $elem_data->actions = $actions;
            $list_data[$heading] = $elem_data;      
        }
        if($heading == 'fabrik_select'){
            $select_class = $el_class;
            $select = $el_data;
            $elem_data->select_class = $select_class;
            $elem_data->select = $select;
            $list_data[$heading] = $elem_data;
        }
     
        $d = @$this->_row->data->$heading;
        if (isset($this->showEmpty) && $this->showEmpty === false && trim(strip_tags($d)) == '') :
            continue;
        endif;
    endforeach;
    //echo '<pre>list_data' . var_export($list_data, true) . '</pre>';
    ?>
    <div class="<?php echo $rowClass; ?>">
        <div class="row-fluid fabrikDivElement">      
            <div class="movie-container">
                <div class="<?php echo $list_data['element_name1']->el_class ?>">
                    <?php echo $list_data['element_name1']->el_data ?>
                </div>
                <div class="<?php echo $list_data['element_name2']->el_class ?>">
                    <?php echo $list_data['element_name2']->el_data;?>
                </div>
            </div>
            <?php if($userGroup == 6 || $userGroup == 8) : ?>
            <!--
                usergroup 6 -> Custom admin
                usergroup 6 -> Super User
            -->
                <div class="<?php echo $list_data['fabrik_actions']->actions_class ?>">
                    <?php echo $list_data['fabrik_actions']->actions ?>
                </div>
                <div class="<?php echo $list_data['fabrik_select']->select_class ?>">
                    <?php echo $list_data['fabrik_select']->select ?>
                </div>          
            <?php endif; ?>
        </div>
    </div>
    But, I am finding two difficulties
    1. Total number of Rows displayed in a Page works for just First page and for others it is random. I have set limit=5 in content plugin. So for first page it displays 5 rows, but when I navigate to 2nd or 3rd page, the limit do not work.
    2. I want to display total n number of Rows, hence I tried to filter the List to display only rows from Last month using date_time element.
    Both $limit & $filter works for bootstrap non-ajax template, but when I use above template they don't. I don't know how to include Filter and Limit option in this DIV Ajax template. Any pointers please.
     
  7. sunnyjey

    sunnyjey Active Member

    Level: Community
    Friendly bump.
     
  8. troester

    troester Well-Known Member Staff Member

    Level: Community
    I can't replicate (with the standard div template).
    content plugin with limit=5 is working fine during navigation
    So as long as you didn't modify anything in default.php it should do.

    Did you use the recent div template as starting point?
     
  9. sunnyjey

    sunnyjey Active Member

    Level: Community
    Yes. Indeed I had made changes in custom layout footer.php. I copied the original footer.php and limit is working fine during navigation.

    Thank you very much for taking time to test this issue and helping me out.
     

Share This Page